Recent changes RSS feed
 

Good Template Smells

Possible criteria for evaluating systems implementing the Template View pattern.

  1. Pass the Dreamweaver test. You should be able to design the website AND the template in Dreamweaver. At any time, you should be able to open the template up in Dreamweaver, make changes visually, modify the template if you made any major changes, and close it with relative ease. It should be noted that just because this is called the Dreamweaver test, it’s really meant to reflect the ability to edit a template in some sort of WYSIWYG editor.
  2. Simplicity. The learning curve for the Templating engine should be small. There are many designers out there, and while some of them can grasp difficult programming methodologies, a lot of them can’t. Just as we programmers might have difficulty grasping the finer points in font selection, we have to assume the same for the designers with regards to programming logic.
  3. Validating. The Template should allow, without any modification, the Template itself to be validated against the W3 validation services.
  4. Cacheable. Whether you are talking about PHP as your templating language, XSLT, or simply a Smarty-style templating engine, every time the engine reads the template and parses it, it wastes time. The template engine should cache the template to prevent having to reparse the template every iteration. PHP based template engines are usually already cached by their very nature of being PHP, but Smarty or XSLT templating engines need this.
  5. Self-Inspecting. Template engines should be self-aware. If a designer uploads, or otherwise modifies a template so that the template is no longer usable, the template engine should NOT allow this to break the existing, working template.
  6. Secure. Template engines, and templates themselves, should be considered insecure, and limited functionality should be in place. Designers and users of the template language are not always trusted members of the staff. Even so-called trusted members of the staff have mean streaks in them. It’s the same reason why everyone at a company logs in to their computer with their own password (or at least should).
  7. Flexibility. The template engine should be built with flexibility in mind. Not all templates created will be HTML based. Therefore, the templating language should evolve to suit those needs. Whether this involves changing the syntax of the template language itself, or merely adding additional functionality to suit the need, so be it. The template engine, of course in the realm of this topic, is suited for use on the web, WML, XHTML, and even SVG are all valid, and important things a template language should work with.

see Bad Template Smells

 
pattern/good_template_smells.txt · Last modified: 2006/12/09 17:14
 
Hosting for this site donated by Procata PHP Development