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 ...@@ -7,13 +7,11 @@ The *TwigExtension* provides integration with the `Twig
Parameters Parameters
---------- ----------
* **twig.path**: Path to the directory containing twig template * **twig.path** (optional): Path to the directory containing twig template
files. files (it can also be an array of paths).
* **twig.templates** (optional): If this option is provided * **twig.templates** (optional): An associative array of template names to
you don't have to provide a ``twig.path``. It is an template contents. Use this if you want to define your templates inline.
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 * **twig.options** (optional): An associative array of twig
options. Check out the twig documentation for more information. options. Check out the twig documentation for more information.
......
...@@ -61,11 +61,10 @@ class TwigExtension implements ExtensionInterface ...@@ -61,11 +61,10 @@ class TwigExtension implements ExtensionInterface
}); });
$app['twig.loader'] = $app->share(function () use ($app) { $app['twig.loader'] = $app->share(function () use ($app) {
if (isset($app['twig.templates'])) { return new \Twig_Loader_Chain(array(
return new \Twig_Loader_Array($app['twig.templates']); new \Twig_Loader_Filesystem(isset($app['twig.path']) ? $app['twig.path'] : array()),
} else { new \Twig_Loader_Array(isset($app['twig.templates']) ? $app['twig.templates'] : array()),
return new \Twig_Loader_Filesystem($app['twig.path']); ));
}
}); });
if (isset($app['twig.class_path'])) { 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