more progress on HTML::Template::Plugin::Dot

rhesa on 2005-08-17T01:55:34

HTML::Template::Plugin::Dot is nearing 1.0!

In the past few days, I've made numerous improvements and bugfixes. The most notable of those is loop support: anything returning an array (or reference to one) can be used in a tmpl_loop:



use HTML::Template::Pluggable; use HTML::Template::Plugin::Dot; use My::Feed; # a Class::DBI object

my $tmpl = q{ Feed: at Items: "" by () };

my $t = HTML::Template::Pluggable->new( scalarref => \$tmpl ); my $feed = My::Feed->retrieve(1); $t->param( feed => $feed ); print $t->output;


Notice how we only pass in the $feed object, and make use of its relationships to display its items. The ':item' suffix works similar to foreach my $item( $feed->items ). I even provide the equivalent of $_ as an implicit local variable, but I've chosen to name it "this", since that's what web designers would be more familiar with than a bare underscore ;-)

The other big improvement is that HTML::Template::Pluggable and ::Plugin::Dot now pass all of the original HTML::Template tests, which means it can be used as a drop-in replacement.

The last bit of big news is that CromeDome has released a plugin for CGI::Application that makes the drop-in even smoother! All you need to do is make a small change to your base class, adding CGI::Application::Plugin::HTDot to its @ISA. All your existing code will keep working as before, but the new dot power is available everywhere, ready for you to tap into.

I'm quite thrilled about my progress, and about CromeDome's plugin :-)

I'm now at a stage where I can go try out all this new power and flexibility. I'm going to see about benchmarking as well; maybe there are performance issues I do not know about yet. But at least it's stable, and that's the important part.