Download the PHP package clawrock/magento2-twig-engine without Composer
On this page you can find all versions of the php package clawrock/magento2-twig-engine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download clawrock/magento2-twig-engine
More information about clawrock/magento2-twig-engine
Files in clawrock/magento2-twig-engine
Package magento2-twig-engine
Short Description Magento 2 Twig Template Engine
License OSL-3.0 AFL-3.0
Informations about the package magento2-twig-engine
Magento 2 - Twig Template Engine
Module implementing Twig as Magento 2 template engine. It works with default .phtml templates as fallback.
Installation
- Install module via composer
composer require clawrock/magento2-twig-engine
- Register module
php bin/magento setup:upgrade
Compatibility
- Magento 2.2 - 2.3
- PHP 7.0 - 7.2
Configuration
There is no system.xml
file, because Twig configuration should be only edited by developers.
Auto resolve option
This module can automatically look for twig files. For example if you want to use twig template in Magento\Theme\Block\Html\Title
block just add file in app/design/frontend/Vendor/theme/Magento_Theme/templates/html/title.html.twig
. If you disable auto resolve you will have to update each block template manually:
Auto resolve option works the same as Magento 2 template resolver. For example if your theme is Luma and template is Magento_Theme::html/title.phtml
it will check possible paths in following order until first existing file:
Extending
Environment options override
XML
Create module dependent on ClawRock_TwigEngine and override values in config.xml
Programmatically
Create before plugin for EnvironmentFactory and modify $options argument.
Create new Twig Extension
Create Extension class extending AbstractExtension or implementing ExtensionInterface and register it with etc/twig.xml
.
Example: ClawRock\TwigEngine\Twig\Extension\MagentoExtension
Important! You can use Magento DI in Twig Extensions.
Resources
All versions of magento2-twig-engine with dependencies
magento/module-store Version ~100.2|~101.0
twig/twig Version ^2.6