

On Using a Templating Language with PHP - csomar
http://omarabid.com/on-using-a-templating-language-with-php/

======
krapp
If you're going to use a templating language on top of PHP, IMHO, just use
Twig. As already mentioned, it compiles templates back into PHP. But, you also
get automatic escaping (with various contexts, such as escaping for html and
escaping for js), hooks to the lexer to write your own tags, filters and
extensions, a function sandbox, and if you're using an older version of PHP,
you can use js-style array and object shorthand ( [] instead of array() and
{key:value} ) in the templates themselves. It is almost a framework
implemented in its own (arguably stricter and saner) language in and of
itself.

Obviously, you _can_ get by without a templating framework. But I find that if
you do, you're either going to have to reimplement features that already exist
in them (in particular, an escaping strategy), or else suffer the consequences
if you don't get it perfect.

------
cweagans
Big debate? Use what works for you. I prefer using Twig because it enforces
not shoving random PHP into your templates, and there's no performance hit for
using it (since it's compiled back to PHP).

------
towelguy
I really like the twig template engine [0]. It will compile your template back
to PHP code so it will run as fast as if you used PHP directly.

[0][http://twig.sensiolabs.org/](http://twig.sensiolabs.org/)

