Hello, Here's a patch to add a plugin system and a first plugin for HTML::Template:
http://mark.stosberg.com/perl/ht-plugin-dot.patch It's rough, but should serve well enough for a conversation piece. The first part is a lightweight plugin system modeled after the successful one that CGI::Application uses, but simplified significantly more for this. From a user's perspective, its presence has no visible effect, and should have a negligible impact on performance (because it does extremely little). There is only one place to hook into the code so far, in param(). I'll provide an example of what this is good for below. While there are several sub classes of HTML::Template, what if you want to use functionality from more than sub class? If they both override param in different ways, it's not possible. The plugin system fixes that. Each plugin can add extra functionality to param(), while cooperating with other plugins. I believe, for example, that this plugin will work fine with HTML::Template::Set without any code changes to it, although it also overloads param(), which my plugin also wants to use. If I had released my functionality as standard sub-class, these two would conflict. ( HTML::Template::Set would allow you to have a header in an include file, while the designer can set the title to display there from the parent file: <TMPL_SET NAME="title">Hi Mom!</TMPL_SET> ) For a first plugin, I have included in the patch HTML::Template::Plugin::Dot, which adds part of Template Toolkit's magic dot notation. This allows dots in a tmpl_var to represent chained method calls or a deeply nested hashref. Because we check for a literal param with dots in it first, it is backwards compatible with current H::T behavior. It's dead simple to use. Just: use HTML::Template; use HTML::Template::Plugin::Dot; Then you can put in your template my_hash.deeply_nested.sage_brush An pull out the right value from here: my_hash => { deeply_nested => { sage_brush => 'You Found Me!' } } Likewise, you could set a param to be a Class::DBI (or compatible) object my_row => $class_dbi_row And then in your template you can call several methods on that object: my_row.num_forks my_row.num_lawsuits And so forth. Looking forward, my plugin system needs some refinement to be polished. Hooks in new() and output() would be useful, and my param() hook could be polished. I welcome coding collaborators on this project. To that end, I have set up a public darcs repository. I have used H::T 2.7 has my base and added my patches to it. To hack on it, just: darcs get http://mark.stosberg.com/darcs_hive/ht-dot/ cd ht-dot # hack.. darcs record # Send me a darcs patch via e-mail. darcs send You can get a darcs binary from http://www.darcs.net/ Thanks! Mark -- 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 _______________________________________________ Html-template-users mailing list Html-template-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/html-template-users