Tuesday, June 28, 2011

Why Template::Toolkit is bad - Component Based Design

Many people like Template::Toolkit and I see it's use a lot in Perl based websites. But I think that it is a bad design practice. In the past I've used Template driven design, where for each view I generate templates.

This works well to start with - but then if you want to tweak every table on the site or every tab panel you need to go in and change every set of templates - now I use "Component Based Design".

Components can be:

  • "structural":
    • Tables;
    • Tabbed panels;
    • Two-col definition lists;
    • Forms;
  • "inline elements":
    • "Protecting" Email addresses;
    • "Abbreviated" URL links (http://Xxx ... adsa/page.html);
    • Citations;
  • "Simple blocks":
    • Captioned (and floated) images;
    • Pull quotes;
    • Marked up HTML/Perl/JavaScript;
    • YouTube embedded videos;
  • "Complex blocks/applications":
    • References;
    • Image galleries;
By generating the HTML using perl code it is easy to tweak the way all components are displayed in one fowl swoop... By keeping the markup clean the look and feel (what the designer has to make look good) is done entirely in CSS, and functionality is driven in Perl.... far far better than the template culture!

PageSmith:: perl modules for making websites

I thought I'd start a brief blog about the new framework I'm working on at the moment, it is the culmination of 14 years of Perl and PHP development into a single easily extensible - but powerful integrated web framework:
  • standards compliant jQuery JavaScript code;
  • standards compliant CSS mark up;
  • standards compliant HTML;
  • mod_perl framework;
  • ability to integrate Java (via mod_jk) and PHP web services;
  • component (NOT template) driven design;
  • integrated development tools;
  • integrated SVN backed publishing system;
  • ...