[htmltmpl] wish: <tmpl_dump>
Brought to you by:
samtregar
From: Mark S. <ma...@su...> - 2005-08-06 23:09:15
|
It should be easier for a designer to get an answer to the question: "What tokens do I have available?" I think there is a fairly reasonable way to make this easier. A <tmpl_dump> tag could be added which outputs all the possible tmpl_loop tmpl_var names, along with their values, right in the template. When the designer is done with this reference, it can be removed. I think the hard part of this implementation is already done, in the form of HTML::Template::Dumper which does basically just this. It can output human-friendly YAML, which could simply be wrapped in a <pre> tag to complete the presentation. All that's left to be done is to add the glue that supports calling this from a new tag. This is another example of a nice feature that could be implemented with a plugin system. I have contacted the author of HTML::Template::Set to see if he would like to make a plugin version of that extension as well. A sample of using HTML::Template::Dumper is below. Mark # Sample HTMl::Template::Dumper script and output #!/usr/bin/perl use lib './lib'; use HTML::Template::Dumper; my $t = HTML::Template::Dumper->new( scalarref => \'<tmpl_var outer><tmpl_loop deloop><tmpl_var inner></tmpl_loop>', ); $t->set_output_format('YAML'); $t->param( outer => 'My Outer', deloop => [ { inner => 'First Inner', }, { inner => 'Second Inner'} ], ); print $t->output(); # output --- #YAML:1.0 deloop: - inner: First Inner - inner: Second Inner outer: My Outer -- http://mark.stosberg.com/ |