default modifiers vs. foreach & if

[email protected] ("Artemy Tregoubenko") Mon, 14 May 2007 13:25:41 +0400
Newsgroups php.smarty.general
Message-ID <op.tsa8g3p7hutq0f@arty-desktop>
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 =3D 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=3D$array_of_arra=
ys",  =

and this generates warning.

Hiding warnings is a bad practice, so I'm looking for another solution f=
or  =

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 w=
ay  =

to fix this?
Or should I write about my problem to dev list?

-- =

Sincerely yours, Arty
[ (i): http://arty.name ]