Commit c6f3f8cc authored by Fabien Potencier's avatar Fabien Potencier

made it possible to use both paths and templates defined in arrays for the Twig extension

parent 3a76a3a0
......@@ -7,13 +7,11 @@ The *TwigExtension* provides integration with the `Twig
Parameters
----------
* **twig.path**: Path to the directory containing twig template
files.
* **twig.path** (optional): Path to the directory containing twig template
files (it can also be an array of paths).
* **twig.templates** (optional): If this option is provided
you don't have to provide a ``twig.path``. It is an
associative array of template names to template contents.
Use this if you want to define your templates inline.
* **twig.templates** (optional): An associative array of template names to
template contents. Use this if you want to define your templates inline.
* **twig.options** (optional): An associative array of twig
options. Check out the twig documentation for more information.
......
......@@ -61,11 +61,10 @@ class TwigExtension implements ExtensionInterface
});
$app['twig.loader'] = $app->share(function () use ($app) {
if (isset($app['twig.templates'])) {
return new \Twig_Loader_Array($app['twig.templates']);
} else {
return new \Twig_Loader_Filesystem($app['twig.path']);
}
return new \Twig_Loader_Chain(array(
new \Twig_Loader_Filesystem(isset($app['twig.path']) ? $app['twig.path'] : array()),
new \Twig_Loader_Array(isset($app['twig.templates']) ? $app['twig.templates'] : array()),
));
});
if (isset($app['twig.class_path'])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment