Twig is a modern, fast, flexible, and secure templating engine for PHP. Created for Symfony and adopted by Drupal 8.
Twig is a modern template engine for php. It is developed for, and used by default, in the symfony2, symfony3, symfony4 and bolt-cms php frameworks, but can also easily be used in other projects. It’s both designer and developer friendly by sticking to PHP’s principles and adding functionality useful for templating environments.
Its key features are (source: https://twig.symfony.com/) :
- Fast: Twig compiles templates down to plain optimized PHP code. The overhead compared to regular PHP code was reduced to the very minimum.
- Secure: Twig has a sandbox mode to evaluate untrusted template code. This allows Twig to be used as a template language for applications where users may modify the template design.
- Flexible: Twig is powered by a flexible lexer and parser. This allows the developer to define its own custom tags and filters, and create its own DSL.
When asking or answering a question, do not hesitate to isolate the problematic code to reproduce it or solve it in an external environment, such as twigfiddle, to get more efficient help or give a working solution.
For more details refer to: