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

In <TMPL_IF> we will give one variable, so it check for
for the value of the variable and include the code inside
it.
But i need to check or condition in <TMPL_IF>
ex:- <TMPL_IF a | b | c>
Is it possible...
I need some help..
--newbie

Retitled by davido.

  • Comment on Can i check various condition in <TMPL_IF> using HTML::Template

Replies are listed 'Best First'.
Re: Can i check various condition in <TMPL_IF> using HTML::Template
by dws (Chancellor) on Jan 18, 2005 at 08:11 UTC

    If you need to check a non-trivial condition when using HTML::Template, you'll have to do it in code. E.g.,

    $template->param(a_or_b_or_c => ($a || $b || $c)); ... <TMPL_IF a_or_b_or_c>

      Hai dws
      I dont want to do it in cgi, i want it in template
      <TMPL_IF a || b || c>
      Is it possible
      --newbie

        I dont want to do it in cgi, i want it in template ... Is it possible

        No, it is not possible in the current release of HTML::Template. If what you want isn't going to go beyond a simple disjunction, then the trick reneeb lays out below will work, though it's going to involve some duplication in the template that you would avoid by calculating the expression in code.

Re: Can i check various condition in <TMPL_IF> using HTML::Template
by reneeb (Chaplain) on Jan 18, 2005 at 09:14 UTC
    What's about:
    <TMPL_IF NAME=a>... <TMPL_ELSE> <TMPL_IF NAME=b>... </TMPL_IF> </TMPL_IF>
    ??
Re: Can i check various condition in <TMPL_IF> using HTML::Template
by dragonchild (Archbishop) on Jan 18, 2005 at 13:39 UTC
    You have now hit one of the many design constraints that samtregar deliberately put into HTML::Template. You might want to consider looking at Template Toolkit if you really want to offload a bunch of the processing to the template in a maintainable fashion.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re: Can i check various condition in <TMPL_IF> using HTML::Template
by jbrugger (Parson) on Jan 18, 2005 at 08:39 UTC