Grep is not behaving as I would expect particularly in the case of a pattern that looks like '^number$'
Is there some escaping or interpolation that I'm missing with pat in this usage? (don't mind the whitespace differences)
TIA, Clayton
[% SET field = {
options => { '1' => 'Chickens',
'12' => 'Ducks' ,
'22' => 'Geese' },
,
values => [ '1' ],
}
%]Expected output like: '22' => 'Geese' selected '1' => 'Chickens' '12' => 'Ducks'
Actual:
[%#
selected '22' => 'Geese'
selected '1' => 'Chickens'
selected '12' => 'Ducks'
%]
[% FOREACH optn = field.options.keys %]
[% SET v = field.options.$optn %]
[% SET pat = '^' _ optn _ '$' %]
[% field.values.grep( pat ) ? "selected" : ''%] '[% optn %]' => '[% v %]'
[% END %]
--- command to run template ---
perl -MTemplate -e' $tt = Template->new({ TRIM => 1}) || die "$Template::ERROR\n"; \
$tt->process("test-template") || die $tt->error(), "\n"'
_______________________________________________ templates mailing list [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates
