[tpm] Automatically generating HTML forms from perl data structures
Uri Guttman
uri at StemSystems.com
Wed Jun 16 14:25:07 PDT 2010
>>>>> "JBL" == J Bobby Lopez <jbl at jbldata.com> writes:
JBL> I'm currently working on some tools which aim to read in JSON
JBL> data into perl data structures (with JSON::XS), and then
JBL> automatically generate TT templates for HTML forms, based on the
JBL> data types of the elements within the data structure.
JBL> So far I have working code, but I was curious if were more common
JBL> ways of doing this? I've searched CPAN for similar modules, but
JBL> haven't found any so far.
JBL> Template Toolkit isn't necessary, but I figured I'd incorporate
JBL> that early since it makes dealing with HTML much less
JBL> cumbersome. The basic goal is to be able to read JSON data and
JBL> dynamically generate an HTML form (without hard-coding any of the
JBL> name/value elements), and then use that form to save the data
JBL> back to JSON format.
to make your life simpler, check out Template::Simple. it can do all the
template work you need but is much simpler (only 4 markups) and much
faster. what you can do is create smaller templates for each type of
data and then build up a larger template from them. then you can render
that with the json data. you can even use the module in a dual role. the
metatemplates would use a different delimiter than the field ones so you
can render both levels given the correct data trees. it really comes
down to how you want your html to look and such. if you can factor out
all common parts and meta parts then you can template it all.
uri
--
Uri Guttman ------ uri at stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
More information about the toronto-pm
mailing list