hulotte/renderer

Manage your template

1.0.0 2020-12-25 06:52 UTC

This package is auto-updated.

Last update: 2024-04-25 14:27:21 UTC


README

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']);