Skip to content

hulotte/renderer

Repository files navigation

Hulotte Renderer

Description

Hulotte Renderer is package to manage template and views with Twig.

Installation

The easiest way to install Hulotte Renderer is to use Composer with this command :

$ composer require hulotte/renderer

How to use Twig with Hulotte Renderer ?

To simplify the use of Twig, Hulotte Renderer has a factory.

$viewPath = './views';
$environment = 'dev'; // can also be 'prod'
$extensions = [
    new TwigExtension1(),
    new TwigExtension2(),
]; // can be nullable

$twigFactory = new \Hulotte\Renderer\Twig\TwigRendererFactory;
$twig = $twigFactory($viewPath, $environment, $extensions);

Now you can render a view. If your view file is "/index.html.twig" :

$twig->render('/index.html');

And if you have parameters to send to the view :

$twig->render('/index.html', ['param1' => 'hello', 'param2' => 'world']);

About

Manage templates with the Renderer package

Resources

Stars

Watchers

Forks

Packages

No packages published