[Templates] using filters within $variables

Axel Gerstmair Axel Gerstmair <anthill@web.de>
Thu, 16 Oct 2003 13:24:46 +0200


Hello Gernot!

On Thursday, October 16, 2003 at 10:46, Gernot Homma wrote:
> [...]
> is there a way to pass the expressions ${i.name} through a filter, like
> [% xxx(myvar = "abc('{$i.name} | html_entity ', '${i.nr}')" %]
> (i know that this syntax does'nt work)

What about storing the value in a temporary variable? For example:

    [% FOREACH i = list %]
    [%     encoded_name = i.name | html_entity %]
    [%     xxx("abc('$encoded_name', '${i.nr}')") %]
    [% END %]

Following this approach even makes the code easier to read! Writing
all in one line may be fine at first but it won't be such a joy
in the long run when you have to maintain the code.

Best regards,
Axel