liamlrb has asked for the wisdom of the Perl Monks concerning the following question:

simple question is either of these legal in HTML::Template or is there another way to do this????
<TMPL_IF EXPR="'Banana' eq <TMPL_VAR FRUIT_FIELD>"> <TMPL_IF EXPR="<TMPL_VARFRUIT_FIELD> eq <TMPL_VAR FOOD_FIELD>">
??????

Replies are listed 'Best First'.
Re: HTML::Template question
by wfsp (Abbot) on Feb 01, 2011 at 08:11 UTC
    As Anonymous Monk has pointed out you may want to consider a different module.

    You might also consider a different approach when using HTML::Template.

    my $fruit_field = q{banana}; my $food_field = q{banana}; my $param = ( is_a_banana => $fruit_field eq q{banana}?1:0, fruit_and_food => $fruit_field eq $food_field?1:0, );
    <TMPL_IF is_a_banana> I'm a banana </TMPL_IF> <TMPL_IF fruit_and_food> eat fruit </TMPL_IF>
    Put the code (your expression) in the script and leave the template to look after the HTML. While I prefer this approach there are many monks who would argue in favour of, say, Template::Toolkit.

    It's up to you which approach best suits your task.

Re: HTML::Template question
by Anonymous Monk on Feb 01, 2011 at 01:00 UTC