gluephp/glue-twig

Use twig templating engine in Glue

0.1.0 2016-05-06 19:38 UTC

This package is not auto-updated.

Last update: 2024-05-20 04:17:48 UTC


README

Use twig/twig with gluephp/glue

Installation

Use Composer:

$ composer require gluephp/glue-twig

Configure Twig

$app = new Glue\App;

$app->config->override([
    'twig' => [
        'path'    => '/absolute/path/to/templates/folder',
        'config'  => [
            // Additional Twig config, read Twigs 
            // documentation for more info...
        ]
    ],
]);

Register Twig

$app->register(
    new Glue\Twig\ServiceProvider()
);

Get the Twig instance

Once the service provider is registered, you can fetch the Twig instance with:

$twig = $app->make('Twig_Environment');

or use the alias:

$twig = $app->twig;