Qiq Templates 2.0 Released
I am happy to annouce the 2.0 release of Qiq templates for PHP 8.
Qiq is for developers who prefer native PHP templates, but with less verbosity. It offers:
- Native
<?php ?>
and{{ qiq }}
syntax - Concise, explicit, context-specific escaping
- Views, layouts, and partials
- Blocks and inheritance
- Rich and extensible HTML helpers
- Easy-to-implement static analysis
- Full documentation and unit-testing
This release incorporates several substantial changes; you can see the upgrade notes here.
The most important of these changes is that Qiq templates are now easily subject to static analysis. Add a docblock typehint for $this
in your template files, recompile any templates using Qiq syntax, and run your static analyzer against your templates. Yes, it's that easy.
The way helpers are implemented has also changed. Previously, you would have to register your helper class with a helper locator, but that made static analysis more difficult. As of this release, helpers are now just methods on a Helpers class, which makes static analysis simple and straightforward. To add a helper, extend the Helpers class and write any method you like. In addition, all helper objects are retained in a PSR-11 container object; use the lightweight Container provided by Qiq, or bring your own (maybe Capsule).
Finally, a Twig-like implementation of "blocks" and "inheritance" has been added to this release, and backported to the latest 1.x release.
If you're a Twig user looking to branch out, or if you like native PHP templates but want something a little more concise, try Qiq!