I have a hash whose keys I am iterating over in Template Toolkit. The example is below....
<SELECT NAME="SelectList_[% feed.num %]" ID="SelectList_[% feed.num %]" SIZE="5" style="width: 250px;" MULTIPLE>
[% FOREACH xvar = feed.xvars.keys %]
<OPTION VALUE="[% xvar %]">[% xvar %]</OPTION>
[% END %]
<OPTION VALUE="X_File_Name">X_File_Name</OPTION>
</SELECT>
What I need to do is to alphabetize this SELECT list (using sort, which I know how to do. Problem is that
<OPTION VALUE="X_File_Name">X_File_Name</OPTION>
line. I was hoping to just add that value "X_File_Name" to the feed.xvars hash. Something like this...
[% feed.xvars = { "X_File_Name" => "1" } %]
hoping that that would add the value to the hash (as opposed to obliterating it). No such luck. Looking in the Template Toolkit book and googling doesn't yield anything either. Anyone know how to do this?
After I asked this I figured it out.
[% appendval = { "X_File_Name" => "1" } %]
[% feed.xvars.import(appendval) %]
There's a far easier approach:
[% feed.xvars.X_File_name = 1 %]
You access individual elements in a TT hash using the dot syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With