[% WHILE i <= max %]
<input type="text" name="field[% i %]" size="24" value="[% "field$i" %]">
[% i = i + 1 %]
[% END %]
Using this snippet of code, I am looping through a list of fields 1 through
max. This works great when the field key I am looking for actually exists.
If I happen upon a field that isn't in the hash then it just prints
out "fieldn".
Here is a sample of output with a hash that might be passed in:
{
field1 => 'foo',
field2 => 'bar',
max => 3,
}
<input type="text" name="field1" size="24" value="foo">
<input type="text" name="field2" size="24" value="bar">
<input type="text" name="field3" size="24" value="field3">
The last input is what I am trying to avoid. I'd like the value to be blank.
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates