When it comes to template engines in PHP, many people will tell you that PHP itself is a template engine. But even if PHP started its life as a template language, it did not evolve like one in the recent years. As a matter of fact, it doesn't support many features modern template engines should have nowadays:
Concise: The PHP language is verbose and becomes ridiculously verbose when it comes to output escaping:
In comparison, Twig has a very concise syntax, which make templates more readable:
Template oriented syntax Twig has shortcuts for common patterns, like having a default text displayed when you iterate over an empty array:
Full Featured: Twig supports everything you need to build powerful templates with ease: multiple inheritance, blocks, automatic output-escaping, and much more:
Of course, PHP is also the language for which you can find the more template engine projects. But most of them do not embrace web development best practices yet:
Secure: When it comes to security, Twig has some unique features:
Automatic output escaping: To be on the safe side, you can enable automatic output escaping globally or for a block of code:
Sandboxing: Twig can evaluate any template in a sandbox environment where the user has access to a limited set of tags, filters, and object methods defined by the developer. Sandboxing can be enabled globally or locally for just some templates:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3