On Tue, Mar 1, 2011 at 12:48 PM, Bill Ward <[email protected]> wrote:

> I know we can use a filter to convert to lower case, [% foo | lower %] but
> that only works for output.  What I want is to do a case-insensitive [% IF
> %] test, and normally in Perl I would just lc($foo) and compare that to the
> desired value.  But how to do that in a template?
>
>
You can pass in any subroutines you like as template variables:

Template->new->process(
    \'[% IF eq_nocase("xxx", "XXX"); THEN; "yes"; ELSE; "no"; END; %]',
    { eq_nocase => sub { lc $_[0] eq lc $_[1] } }
);
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to