Template Toolkit's dot notation is almost ready for a CPAN release a
plugin for HTML::Template.
I would like to see HTML::Template support plugins directly, but I
intend to release HTML::Template::Pluggable as a sub-class so the
functionality can be publicly available until that time.
However, the dot notation still won't work inside of loops without a
trivial patch to HTML::Template to remove the hardcoding of the package
name in one place:
A preview release is here:
And some of the documentation is below.
Special thanks go to Rhesa Rozendaal for collaborating with me on this,
and to David Baker, Jason Crome and others for cheering us on.
my $t = HTML::Template::Pluggable->new(...);
Now you can use chained accessor calls and nested hashrefs as params,
and access them with a dot notation. You can even pass basic arguments
to the methods.
For example, in your code:
$t->param( my_complex_struct => $struct );
And then in your template you can reference specific values in the
By adding support for this dot notation to HTML::Template, the program-
mers job of sending data to the template is easier, and designers have
easier to access to more data to display in the template, without
learning any more tag syntax.
Class::DBI accessors can be used in the template. If the accessor is
never called in the template, that data doesn't have to be loaded.
In the code:
$t->param ( my_row => $class_dbi_obj );
In the template:
DateTime is a great date date formatting module. By using it with this
plugin, you can leave the date formatting in the template, where a
savvy designer can adjust it.
$t->param ( my_date => $dt_obj );
In the template:
Of course, if date formatting strings look scary to the designer, you
can keep them in the application, or even a database layer to insure
consistency in all presentations.