wish: <tmpl_dump>

Mark Stosberg <mark-WmyhgDpj2fCHT8/[email protected]>
Newsgroups gmane.comp.lang.perl.modules.html-template
Message-ID <[email protected]>
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/ 



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.