On Tue, Mar 1, 2011 at 1:04 PM, Sean McAfee <[email protected]> wrote:
> 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] } } > ); > > Yes but surely there's a better way? This is a pretty fundamental feature of any language.
_______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates
