[Templates] Patterns for modular templates

Nik Clayton nik@ngo.org.uk
Wed, 27 Sep 2006 18:27:27 +0100


Can anyone recommend any particular "design patterns" for creating 
modular templates that make it easy for third parties to create "plugins"?

To be more specific -- I'm the maintainer of SVN::Web.  Output is fully 
templated, using TT2.  The application itself is modular, and broken 
down in to actions carried out by plugins.

This works well -- adding new actions is a case of installing the plugin 
and updating the application config file.

The only problem is that if a plugin needs to change the output for some 
reason then the only mechanism I've got for that at the moment is to 
tell the person installing the plugin

    ... When you've finished installing, you need to edit the following
    templates by hand, and include some HTML.  That HTML should look
    something like this ...

For example, if you take a look at http://jc.ngo.org.uk/svnweb/jc/ 
you'll see a "View timeline" link.  That's not there in the default 
SVN::Web install.  You need to install SVN::Web::Timeline (which I'll 
get around to releasing once I've resolved this issue to my 
satisfaction), and then edit the template.

Or consider SVN::Web::Search, which I'll get around to releasing one of 
these days.  The installation section of the documentation

http://jc.ngo.org.uk/svnweb/jc/view/nik/CPAN/SVN-Web-Search/trunk/lib/SVN/Web/Search.pm

has a big glob of HTML for the user to cut/paste.  I'm not sure that's 
really acceptable.

I can solve this in an SVN::Web specific way, but I'm casting around for 
an approach that might be a bit more generic.

Any thoughts?

N