I have used the same scenario.
I have found that "sometimes" you CAN access a perl variable, via the
template by appending the dollar sign and sending it in the vars hash. It
will be available to the Template::Provider and Template::Grammer mods. (I
think, help me out Andy)
Like so:
in perl script:
my $var = (this) || (that);
$template->process('Template', { var => $var}) || die "etc...";
Then in Template:
[% IF $var == "this" %]
do something
[% ELSE %]
something else
[% END %]
For the selected option group I made a variable in my config template:
(CONFIG TEMP)
selected = 'selected="selected"'
Then pass the options array to the template and cycle through them.
(PERL)
my @options = sort qw(one two three four five);
my $choice = $q->param('choice');
$template->process('Template', { options => [EMAIL PROTECTED], choice =>
$choice })
|| die "etc..";
(TEMP)
<select name="one">
[% foreach item IN options %]
[% IF item == choice %]
<option value="[% item %] selected>[% item %]</option>
[% ELSE %]
<option value="[% item %]">[% item %]</option>
[% END %]
[% END %]
</select>
Hope it helps!!
On Mon, Apr 14, 2008 at 2:31 AM, Andy Wardley <[EMAIL PROTECTED]> wrote:
> Daniela Wersin wrote:
> > I want to prevent
> > components to appear in that list whose name begins with "Z -". How do I
> > do that?
> >
> > <td>
> > <select name="component" onchange="set_assign_to();" size="5">
> > [%- FOREACH c = product.components %]
>
> [% NEXT IF c.name.match('^Z') %]
>
> (or put the inner block in an UNLESS c.name.match('^Z') ... END block)
>
> HTH
> A
>
>
>
> _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates
>
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates