...when you need to cover your Twig with smoke.
composer require tomasvotruba/torch --dev
- Create
torch.php
in your project root:
use Twig\Environment;
require_once __DIR__ . '/vendor/autoload.php';
// create instance of Environment with everything needed for smoke render
$environment = new Environment(...);
return $environment;
In this file, you can override existing twig functions:
// override twig functions you need
StaticParameterProvider::set('overrideFunctions', [
// provide static value for dynamic function
'baseTemplate' => function () {
return DummyTheme::LAYOUT_NAME;
},
]);
- Run torch your twig files directories:
vendor/bin/torch run templates
- https://tomasvotruba.com/blog/twig-smoke-rendering-why-do-we-even-need-it/
- https://tomasvotruba.com/blog/twig-smoke-rendering-journey-of-fails/
- https://tomasvotruba.com/blog/twig-smoke-rendering-fortune-favors-the-bold
Happy coding!