Patch to add TT's dot notation to HTML::Template

markjugg on 2005-08-02T23:24:22

Last night I hacked in support for the basics of TT's "dot notation" for template variables into HTML::Template.

Here's my patch with code and tests, but no docs yet.

For those just tuning into the templating competition, one of the cool features of TT is that you can reference a value in a deeply nested hash or a chain of method calls directly in the template with the dot notation, like this:

    my_hash.deeply_nested.sage_brush
    my_obj.has.chained.methods_galore

In the code only have to make the single hashref or object available to make this work:

 my_hash => \%foo,
 my_obj  => $obj,

I don't see that this violates the philosophy of HTML::Template, because from the designers perspective, hardly anything as changed. Before they had a list of tmpl_vars to work with, and now they have the same thing, but the life of the programmer is easier.

I have begun discussing how to best release this functionality with Sam Tregar, and expect to involve the mailing list now that Gmane is available for me to post again. At this point, I think having it in the core, in a sub-class or as a plugin (for a yet-to-be-developed) plugin system are all possibilities.


Very cool

davebaker on 2005-08-03T02:41:05

I look forward to playing with this! Very cool, Mark.