default modifiers vs. foreach & if

From: Date: Mon, 14 May 2007 09:25:41 +0000
Subject: default modifiers vs. foreach & if
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13707@lists.php.net to get a copy of this message
Hello everyone. I just tried to use this nice feature of smarty: http://smarty.php.net/manual/en/variable.default.modifiers.php I think that auto-escaping of all values when outputting them is a great idea, so i set $this->default_modifiers = array('escape:"html"'); It worked nice until I tried to use foreach to iterate over array of arrays. I got lots of messages like this: Warning: htmlspecialchars() expects parameter 1 to be string, array given... The same warnings were displayed when using "{if $array}". I looked into compiled templates and found that smarty applies default modifiers to all parameters of foreach, including "from=$array_of_arrays", and this generates warning. Hiding warnings is a bad practice, so I'm looking for another solution for this problem. By now I hacked _compile_foreach_start and _compile_if_tag so that default_modifiers are toggled off in the beginning and restored at the end of methods. I understand this is only partial solution. Can anyone, having deeper knowledge of smarty compiler, suggest better way to fix this? Or should I write about my problem to dev list? -- Sincerely yours, Arty [ (i): http://arty.name ]

« previous php.smarty.general (#13707) next »