in reply to Re: Template Toolkit and booleans
in thread Template Toolkit and booleans

<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!

Replies are listed 'Best First'.
Re: Re: Re: Template Toolkit and booleans
by perrin (Chancellor) on Feb 11, 2003 at 17:21 UTC
    [%- 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!