The best template engine is no template engine.

Another love letter to Processwire. <3

Do you know what a template engine is? Then you can jump directly some paragraphs ahead. For those of you who don't know it I'll try to explain it as simple as possible.

A template eninge is kind of a custom trimmed programming language only containing those stuff you need for frontend development. Here is a quick example  using the popular PHP template engine "smarty":


In this case {$title} would return the page's title. Same with WordPress - more or less - template engine:

 <title><?php wp_title(); ?></title>

In case of WordPress the template engine only contains PHP functions you can use for frontend development. So it's not a really real template engine but it tries to be.

Of course returning the title is an easy example. But what if it comes to conditions? Like: Only show this image if this is a single page?

In Smarty you would have special syntax again. In WordPress you would use regular PHP conditions-syntax.


You probably know the saying "Time is money". It's true. So it's worth to take a look at time in ths case: How long does it take to learn a template engine language?

I think it's like with every programming language: You'll never going to know each command. But after a time you will understand how it works. Even things which seems really strange like WordPress' "The Loop".

In case of smarty you probably would really "only" have to learn it's syntax - but I don't know a popular CMS using Smarty as main templte language. As for WordPress you'd probably have to learn some PHP stuff, too. At least for loops and conditions. Double effort. Great.

Do I really need a template language?


I never understood why CMS' are using template engines which needs to be rendered as the page loads, too. So it costs time to learn the language. It costs time to render the language. And there is no real advantage of it.

What do you suggest?

Well why not just returning PHP variables containing the whole data? Sounds great? Well, it's exactly what ProcessWire is doing. You don't need to learn a new language if you already know PHP. Otherwise you just have to learn it's basics because the ProcessWire way is really easy.

Returning the title would be like:

 <title><?php echo $page->title; ?></title> 

Much more logical, cleaner and flexible. Exactly how I want it to be.


Go download ProcessWire and lt it speak for itself.


Do you disagree with me and know a reason why I should like template engines (or WordPress itself)? Go ahead and tell me @derStadtpirat.