James,

This works for me  [% ${"field$i"} %] as in:

[% i = 1 %]
[% WHILE i <= max %]
<input type="text" name="field[% i %]" size="24" value="[% ${"field$i"}
%]"> [% i = i + 1 %] [% END %] 


Christian 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of James Lance
Sent: 02 October 2006 23:28
To: [email protected]
Subject: [Templates] Variable Oddness

[% 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.


http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal 
views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on 
it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.
                                        

_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to