Smarty [1] gives us a simple way to escape “dirty” variables when they come to template processing. With escape variable modifier [2] you can make “dirty” things look smart. You can escape or even remove html tags and special characters.
Variable in a Smarty template without escaping {$articleTitle}
and with escaping {$articleTitle|escape:'html'}But if you are lazy like me you might wonder what the need to write “escape:’html’” again and again for all variables. Good new is that we can make Smarty do it by default by setting $default_modifiers [3] field for Smarty object. For lazy guys here is sample
$smarty->default_modifiers = array('escape:"html"');We can turn off this “defaul” behaviour for selected variables with
{$var|smarty:nodefaults}Be Smarty and good luck! :)
Links:
[1] http://www.smarty.net/
[2] http://www.smarty.net/manual/en/language.modifier.escape.php
[3] http://www.smarty.net/manual/en/variable.default.modifiers.php