PHP templating engines usually define their own syntax. So, to produce HTML you need to learn a new language and use different tools for development. That's something I've always found strange. HTML data is just text and PHP has no trouble manipulating text.
Compare it with software to interact with databases. Then we use PHP components that create a representation of the database elements. These components interface with the database and manipulate the stored data.
We don't write software and ask a database administrator to define all the SQL statements to manipulate the database as she thinks is best. But that's what we're doing with HTML data.
So, why not use PHP directly to create HTML data?
This is what fillum-html does.
fillum-html is a plain PHP component to generate HTML output directly in PHP code. The advantages of using this library over a dedicated templating system:
- there is no need to learn a separate template language.
- all normal PHP tools to develop, refactor and test source code can be used.
- HTML output and the elements are PHP objects. This allows normal manipulation and extension using object oriented techniques.
- there are no separate templates to compile or interpret.
fillum-html is available on packagist so it's easy to include in your project.