The FrctlTwigExtension component allows you set seamlessly integrate your Fractal twig templates.
To install the latest stable version of this component, open a console and execute the following command:
$ composer require candoimage/frctl_twig
The first step is to register the extension in the twig environment
services:
Frctl\Twig\Extension\FrctlTwigExtension:
tags:
- { name: twig.extension }
or manually in your code
/* @var $twig Twig_Environment */
$twig->addExtension(new Frctl\Twig\Extension\FrctlTwigExtension());
Then you need to configure the new include namespace the fractal templates:
twig:
paths:
'%kernel.project_dir%/../frontend/src/components': FrctlTwig
or manually in your code
$loader->addPath(dirname(__DIR__) . '/../frontend/src/components', 'FrctlTwig');
Once registered, you can use the new render
tag seamlessly in your twig templates:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
</head>
<body>
{% render "@component" with {some: 'values'} %}
</body>
</html>
This component is under the MIT license. See the complete license in the LICENSE file.
Issues and feature requests are tracked in the Github issue tracker.
If you find this component useful, please add a ★ in the GitHub repository page.