Simon Wilcox wrote:
> How about writing out a TT template from the perl programme instead of
> using Data::Dumper. Then you can just PROCESS it in the normal way.

Yep, that's certainly the way I do it.

> You can even use TT to generate it (untested):

Yep, ditto.  It's also worth single quoting and escaping the hash keys,
in case they contain any non-word characters.  Here's one of my generator
templates which spits out all the key/value pairs in the 'data' hash.

[% MACRO escape(text) GET text.replace("'", "\\'") -%]
[% TAGS star -%]
[% # this data is generated by the <mumble> process
[* FOREACH kv IN data -*]
   '[* escape(kv.key) *]' = '[* escape(kv.value) *]'
[* END -*]
%]


A


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

Reply via email to