Why should I use templating system in PHP?
The reasoning behind my question is: PHP itself is feature rich templating system, why should I install another template engine?
The only two pros I found so far are:
- A bit cleaner syntax (sometimes)
- Template engine is not usually powerful enough to implement business logic so it forces you to separate concerns. Templating with PHP can lure you to walk around the templating principles and start writing code soup again.
... and both are quite negligible when compared to cons.
Small example:
PHP
<h1><?=$title?></h1>
<ul>
<? foreach ($items as $item) {?>
<li><?=$item?></li>
<? } ?>
</ul>
Smarty
<h1>{$title}</h1>
<ul>
{foreach item=item from=$items}
<li>{$item}</li>
{/foreach}
</ul>
I really don't see any difference at all.