public function replaceTemplateVariables($data)
    {
        $this->assertDataIsWritable();

        if ($templateVariables = $this->getOption('templateVariables', [])) {
            $templateVariableKeys = array_keys($templateVariables);

            if (is_string($data)) {
                $data = str_replace($templateVariableKeys, $templateVariables, $data);
            } else if (is_array($data)) {
                array_walk_recursive(
                    $data,
                    function(&$value, &$key, &$data) {
                        $value = str_replace($data['keys'], $data['values'], $value);
                    },
                    [
                        'keys'      => $templateVariableKeys,
                        'values'    => $templateVariables
                    ]
                );
            }
        }

        return $data;
    }