Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

rhesa (5696)

rhesa
  (email not shown publicly)

Journal of rhesa (5696)

Tuesday August 16, 2005
08:55 PM

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

[ #26311 ]

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: <tmpl_var feed.name> at <tmpl_var feed.url>
Items:<tmpl_loop feed.items:item>
    "<tmpl_var item.title>" by <tmpl_var item.author> (<tmpl_var item.postdate.dmy>)
</tmpl_loop>
};
 
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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.