Dumb Idea: Let’s write a new templating language

At work, we’re going to be redesigning a site that is running Textpattern.  As I’ve never worked with Textpattern before, I’ve been brushing up.  After about two minutes of reading, I find out that it has it’s own XHTML-style templating language.  Textpattern immediately loses a lot of credibility.

The article I was reading rationalizes the creation of Textpattern’s templating language:

Textpattern is aimed squarely at web designers, not PHP geeks or novice bloggers. Its template tags use a syntax that’s identical to XHTML, and thus familiar and convenient for designers.

Templates specify presentation, so they’re written in a style already familiar to a web designer. A PHP-based template syntax might be convenient for software developers, but PHP is a procedural programming language, not a markup language.

Although there are a couple points in these excerpts that are correct (i.e. “templates specify presentation” and “PHP is a procedural programming language, not a markup language”), the logic is just plain wrong.  Sure, the templating language has the same “style” as XHTML, but it’s not XHTML.  So no matter what other languages (templating or programming) the designer is already familiar with, they still have to learn this new one.

I am a fan of PHP-based template languages for three fundamental reasons:

  1. There’s hardly anything to learn if you’re already familiar with PHP (a lot of people are, even “designers”)
  2. If you aren’t already familiar with PHP, you learn a useful language
  3. PHP is very well documented (unlike some of these templating languages)

And why an XHTML-style templating language?  The author of the article contends that designers are already familiar with that style.  But who are these designers anyway?  Designers may have dealt with templating in the past, but nowadays they generally stick to Photoshop and Illustrator.  The frontend developers are usually the ones dealing with templates and they never deal exclusively with markup.  They are also into CSS and usually Javascript as well.  And since the basic control structures (if, else, while, for, etc.) in Javascript and PHP have nearly identical syntaxes, a PHP-based template language would be a lot more natural for frontend developers.

And even if you’re hell bent on creating an XHTML-style templating system, why invent a new language?  Because it’s fun is not a good reason.  There’s lots of popular languages already out there.  Perl’s HTML-Template is a good example.

So, unless you’ve come up with some innovative templating syntax, writing a new templating language is not only reinventing the wheel, it’s just plain dumb.