srins has asked for the wisdom of the Perl Monks concerning the following question:
as $template->process($file,%add) || die $template->error(); for my hash my %add=( hsh1=>{ name=>"name1 ", type =>"text", default=>" ", value=>[" "], entries=>"M" }, hsh2=>{ name=>"name2 ", type=>"dropdown", req=>"prc", default=>" ", value=>["value1","value2","value3"], entries=>" " } ); for your code [% FOREACH element = add.keys %] [% IF add.$element.type == "text" %] <input type="text" name="[% add.$element.name %]" value="[% add.$e +lement.default %]"> [% ELSIF add.$element.type == "dropdown" %] <select name="[% add.$element.name %]"> [% FOREACH option = add.$element.value %] <option value="[% option %]"> [% option %] </option> [% END %] </select> [% END %] <br> [% # put a line break between the form elements %] [% END %]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to pass hash to perl template toolkit
by johnnywang (Priest) on Nov 05, 2005 at 20:48 UTC | |
by nikmit (Sexton) on Nov 28, 2015 at 09:12 UTC | |
by beech (Parson) on Nov 28, 2015 at 09:38 UTC |