People credit PHP’s ability to blend-in with HTML as one of the most important reason for it’s popularity. So I contemplated it as a templating language today.
Turns out, PHP is not anywhere near an impressive templating language after all.
To me, the deal breaker is its inability to achieve template inheritance, something Python web developers take granted for. In Jinja2 or Django’s templating language, a template can “implement” blocks declared in its parent template, whose code is shared among its children. To the controllers, this mechanism is completely hidden, so they simply use those “child” templates to render everything, as if they are full-fledged templates.
With PHP, intuitively, similar functionality can be done with ‘include’ & co. You can take one of two approaches:
Either way, you get one level of “inheritance” done.
To be fair though, a library is all that’s need to bring PHP back into the game.