Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 15970

How to load a template from full path in the template engine TWIG

$
0
0

I'm wondering how to load a template from it's full path (like FILE constant give).

Actually you have to set a "root" path for template like this :

require_once '/path/to/lib/Twig/Autoloader.php';Twig_Autoloader::register();$loader = new Twig_Loader_Filesystem('/path/to/templates');$twig = new Twig_Environment($loader, array('cache' => '/path/to/compilation_cache',));

And then :

$template = $twig->loadTemplate('index.html');echo $template->render(array('the' => 'variables', 'go' => 'here'));

I want to call the loadTemplate method with a full path and not the just the name of the file.

How can i do ?

I don't want to create my own loader for such an thing..

Thanks


Viewing all articles
Browse latest Browse all 15970

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>