Commit 96640c27 authored by Fabien Potencier's avatar Fabien Potencier

made it possible to add templates or template paths dynamically in Twig extension

parent c6f3f8cc
......@@ -60,10 +60,18 @@ class TwigExtension implements ExtensionInterface
return $twig;
});
$app['twig.loader.filesystem'] = $app->share(function () use ($app) {
return new \Twig_Loader_Filesystem(isset($app['twig.path']) ? $app['twig.path'] : array());
});
$app['twig.loader.array'] = $app->share(function () use ($app) {
return new \Twig_Loader_Array(isset($app['twig.templates']) ? $app['twig.templates'] : array());
});
$app['twig.loader'] = $app->share(function () use ($app) {
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()),
$app['twig.loader.filesystem'],
$app['twig.loader.array'],
));
});
......
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