*/
function twig_template_from_string(Twig_Environment $env, $template)
{
+ $name = sprintf('__string_template__%s', hash('sha256', uniqid(mt_rand(), true), false));
+
$loader = new Twig_Loader_Chain(array(
- new Twig_Loader_Array(array('__string_template__' => $template)),
+ new Twig_Loader_Array(array($name => $template)),
$current = $env->getLoader(),
));
$env->setLoader($loader);
try {
- $template = $env->loadTemplate('__string_template__');
+ $template = $env->loadTemplate($name);
} catch (Exception $e) {
$env->setLoader($current);