///The death of templating engines

The death of templating engines

Ladies and Gentlemen, we have an impending death of templating engines on our hands.

I won’t go as far as to speculate we’re beyond the death of templating engines, but the facts of the matter are this:

  1. Templating engines seperate presentation from logic.
  2. Today’s frameworks seperate presentation from logic.
  3. Any good developer not using a framework either seperates presentation from logic anyway, or has a good reason for not doing so.

So… while it’s great that we have some very sophisticated templating systems available, the world of PHP application development has changed considerably since templating engines were created. The idea of seperation of presentation and logic is still as important as it was, but PHP scripts are no longer the procedural top-to-bottom spaghetti messes they once were.

We no longer have echo calls interspersed with complex database logic, function/method return values output directly and so on. With the widespread availability of PHP frameworks (especially MVC-based), and the low barrier of entry to creating your own, any developer can seperate their presentation from logic as a matter of habit.

Templating engines, then, fill a gap that no longer exists. By creating a new templating language and enforcing it upon the developer, Smarty helped many developers cleanly seperate their presentation…

… back in 2004.

I’m not suggesting Smarty is now useless, dated or simple ineffective for today’s development challenges, but the main problem of these templating engines was the language they introduced. Runtime-compiled templates with a specialised language meant that not only did you have to learn new syntax altogether, you also had major performance issues with your application.

Now, don’t get me wrong. Smarty was a fantastic idea back then. It really solved the issue of a templating system for PHP, as did similar projects. It’s still in widespread use. But now we have alternative syntax, and efficient pure-PHP systems for templating, and the whole concept of a dedicated templating language is simply not the same.

Finally, today’s PHP frameworks enforce this clean seperation out of the box. Developers understand the importance of this seperation and use it effectively. Designers I work with are happy to modify my CodeIgniter or CakePHP view files when making changes to designs. They understand PHP’s alternative syntax for control structures. It works for everyone. Given this, it won’t be long till we all simply move on from external templating engines.

Look at it this way. Hasin Hayder literally wrote the book on Smarty. He himself accepts that we no longer need it. What more can I say?

2008-02-22T07:44:05+00:00 February 22nd, 2008|PHP|0 Comments

About the Author:

Leave A Comment