in reply to Template Toolkit and booleans

Are you using the DBI plugin or querying from Perl code and passing the values to TT?

Replies are listed 'Best First'.
Re: Re: Template Toolkit and booleans
by talexb (Chancellor) on Feb 11, 2003 at 17:09 UTC
    <table width="100%"><tr> [% FOREACH priv = [ "priv_upload", "priv_inspect", "priv_download", + "priv_admin" ] %] <td align="center">[% priv %] = "[%- line.priv -%]" </td> [% END %] </tr></table>

    I'm trying to use a loop to go through privileges for an account .. the variable 'priv' comes through fine but 'line.priv' comes up empty, perhaps because TT2 is looking for line.priv instead of line.priv_upload which is what I want. I'm not sure how I can get this interpolation to happen.

    --t. alex
    Life is short: get busy!
      [%- line.$priv - %]

      See the section on variable interpolation in the TT manual.

        <table width="100%"><tr> [% FOREACH priv = [ "upload", "inspect", "download", "admin" ] %] [% field = "priv_$priv" %] <td align="center">[% priv %] = "[%- line.$field -%]" </td> [% END %] </tr></table>

        And now I can simplify it to this .. Thanks!

        --t. alex
        Life is short: get busy!