This skill is an integration of Twig
into Jarvis micro-framework.
When this skill is enabled, it brings:
$app['twig']
service, an unique instance of\Twig_Environment
.- On
$app['twig']
first call, the eventJarvis\Skill\Twig\TwigReadyEvent
(event name:twig.ready
) will be broadcasted. Note thatTwigReadyEvent
is a permanent event. - In all Twig templates, the variable
router
(=$app['router']
) is available.
You must add a 'twig' key in the 'extra' section to pass your options:
<?php
require_once __DIR__ . '/vendor/autoload.php';
$app = new Jarvis\Jarvis([
'providers' => [
'Jarvis\Skill\Twig\TwigCore',
],
'extra' => [
twig' => [
'templates_paths' => '/path/to/templates',
],
],
]);
Note that templates_paths
is a required parameter. Other options:
debug
: if not provided, Jarvisdebug
parameter is used.auto_reload
:true
by default.strict_variables
:true
by default.
You can see complete options list on Twig documentation.