eric-chau/twig-skill

There is no license information available for the latest version (v1.0.1) of this package.

v1.0.1 2016-10-12 17:30 UTC

This package is not auto-updated.

Last update: 2024-04-27 15:31:42 UTC


README

This skill is an integration of Twig into Jarvis micro-framework.

What it brings

When this skill is enabled, it brings:

  • $app['twig'] service, an unique instance of \Twig_Environment.
  • On $app['twig'] first call, the event Jarvis\Skill\Twig\TwigReadyEvent (event name: twig.ready) will be broadcasted. Note that TwigReadyEvent is a permanent event.
  • In all Twig templates, the variable router (=$app['router']) is available.

Configuration options

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, Jarvis debug parameter is used.
  • auto_reload: true by default.
  • strict_variables: true by default.

You can see complete options list on Twig documentation.