Menu

<TMPL_IF [VAR]=[value]>, does this exist?

2001-01-19
2001-07-12
  • Bill Robinson

    Bill Robinson - 2001-01-19

    Hi all,

    I have RTFM'd and believe the answer is "No; However, I wanted to confirm that this was true.  Is it present and I am missing it? Or is there a way to do something like it, that I am not catching on to?

    Sincerely,
    Sifmole

     
    • Andrey Melnikov

      Andrey Melnikov - 2001-03-02

      I don't think that we are going to make something like CFML. So we should avoid any logic in the templates. The solution is to make a set of boolean template variables manually:

      $template->param( xxx_a => ($xxx eq 'a') )

      or something like this

       
      • Conny Brunnkvist

        In most cases (when the data source is trusted) why not simply assign the value you want to check to a boolean:

        $xxx='a';
        $template->param( $xxx => 1 );

        and have the template do:
        <TMPL_IF a>print something</TMPL_IF>
        <TMPL_IF b>print something else</TMPL_IF>

        OVERKILL or perhaps a last resort, is to make a nested IF-ELSE statement, or if you think it gets more readable, a nested UNLESS-ELSE!!:

        <TMPL_UNLESS alpha>
            <TMPL_UNLESS bravo>
                <TMPL_UNLESS charley>
                    This is the default!
                <TMPL_ELSE>
                    This is for charley!
                </TMPL_UNLESS>
            <TMPL_ELSE>
                This is for bravo!
            </TMPL_UNLESS>
        <TMPL_ELSE>
            This is for alpha!
        </TMPL_UNLESS>

        ;-D

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.