public function Twig_Environment::createTemplate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/twig/twig/lib/Twig/Environment.php \Twig_Environment::createTemplate()
Creates a template from source.
This method should not be used as a generic way to load templates.
Parameters
string $template The template name:
Return value
Twig_Template A template instance representing the given template name
Throws
Twig_Error_Loader When the template cannot be found
Twig_Error_Syntax When an error occurred during compilation
File
- vendor/
twig/ twig/ lib/ Twig/ Environment.php, line 426
Class
- Twig_Environment
- Stores the Twig configuration.
Code
public function createTemplate($template) {
$name = sprintf('__string_template__%s', hash('sha256', uniqid(mt_rand(), true), false));
$loader = new Twig_Loader_Chain(array(
new Twig_Loader_Array(array(
$name => $template,
)),
$current = $this
->getLoader(),
));
$this
->setLoader($loader);
try {
$template = $this
->loadTemplate($name);
} catch (Exception $e) {
$this
->setLoader($current);
throw $e;
}
$this
->setLoader($current);
return $template;
}