Not to be dense, but why do you need to re-write the hash? You did all the work to build it, why should your templating system not handle it? I used HTML::Template a few years ago and am actually surprised that this type of thing continues to be an issue. I can't help much with H::t but here is the TemplateToolkit foo to do it. (showing another available option)
[% 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 %]
In your perl code you would just pass the add hash into the TemplateToolkit process routine.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.