Chris Petersen wrote: > I realize that it's somewhat un-perl, but is there a way to do "in" > within TT? It would be nice to keep things clean when I have large > lists of things I'm comparing a single variable to in an if-statement. > > [% IF var == 'foo' || var == 'bar' %] > > I've tried to use something like: > > [% IF [ 'foo', 'bar' ].grep(var) %] > > But it obviously fails. > > I realize that I can write my own vmethod for this, but it would be > nice if something like this was already built in, so I could just: > > [% IF var IN ['foo','bar'] %] > > or > > [% IF var ! IN ['foo','bar'] %]
There's always var.match('^(foo|bar)$') -- Josh _______________________________________________ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates