Open raxell opened 10 years ago
why don't add it to this lib?
Maybe for conformance with Slim setting templates.path
?
Currently, I am modifying it on the fly
$twigInstance = $app->view->getEnvironment();
$twigLoader = new Twig_Loader_Filesystem();
foreach ($templatePaths as $path) {
$twigLoader->addPath($path);
}
$twigLoader->addPath($app->config('templates.path'));
$twigInstance->setLoader($twigLoader);
Maybe for conformance with Slim setting
templates.path
?
templates.path
should refers to the template engine you are using, not to the Slim default setting. If Twig gives the option to choose more dirs for templates, why shouldn't I be able to use this option in Slim for the Twig engine?
@ikhsan017 I know that I can change the loader, but why use this "trick" when the configuration can be setted in the Slim constructor? This modify only affect Twig, for other template engine you can continue to use a string.
templates.path
The relative or absolute path to the filesystem directory that contains your Slim application’s template files. This path is referenced by the Slim application’s View to fetch and render templates.
To change this setting after instantiation you need to access Slim’s view directly and use its setTemplatesDirectory() method.
I fully agree with you @raxell we will be revisiting this for Slim 3 as View will manage their own config at that point. What would you suggest for the current Slim 2.4.* builds?
Can you add support for setting multiple templares dirs? Twig already support it, why don't add it to this lib?
Simply edit in Slim\Views\Twig: