Qiq Templates for PHP 8
I'm happy to announce the first release of Qiq, a template system for developers who prefer native PHP templates -- but with a light dusting of syntax sugar when you want it. It offers partials, layouts, sections, and a wide range of HTML helpers for tags and forms, along with explicit but concise escaping.
I don't like compiled templates or specialized template languages. Smarty, Twig, etc., are all just too heavy-handed. I don't need a new language, and I don't need to "secure" my templates against designers on my team. I am generally happy with plain PHP as a template language.
However, I do find escaping tedious -- necessary, and easy enough, but tedious. A template helper to output escaped HTML, like this ...
<?= $this->h($var) ?>
... is not that bad -- but even so, it could be a little easier. Imagine this little bit of syntax sugar:
{{h $var }}
All that happens is that {{h ... }}
is replaced with <?= $this->h(...) ?>
.
Once that is in place, it becomes easy to support helpers, control structures, and other code, all while keeping native PHP as the fallback syntax, because the {{ ... }}
tags are essentially stand-ins for PHP tags.
Qiq is PHP -- just with some syntax sugar. Try it out on your next project!