public function Twig_Environment::loadTemplate in Translation template extractor 6.3
Same name and namespace in other branches
- 7.3 vendor/Twig/Environment.php \Twig_Environment::loadTemplate()
Loads a template by name.
Parameters
string $name The template name:
int $index The index if it is an embedded template:
Return value
Twig_TemplateInterface 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
1 call to Twig_Environment::loadTemplate()
- Twig_Environment::resolveTemplate in vendor/
Twig/ Environment.php - Tries to load a template consecutively from an array.
File
- vendor/
Twig/ Environment.php, line 321
Class
- Twig_Environment
- Stores the Twig configuration.
Code
public function loadTemplate($name, $index = null) {
$cls = $this
->getTemplateClass($name, $index);
if (isset($this->loadedTemplates[$cls])) {
return $this->loadedTemplates[$cls];
}
if (!class_exists($cls, false)) {
if (false === ($cache = $this
->getCacheFilename($name))) {
eval('?>' . $this
->compileSource($this
->getLoader()
->getSource($name), $name));
}
else {
if (!is_file($cache) || $this
->isAutoReload() && !$this
->isTemplateFresh($name, filemtime($cache))) {
$this
->writeCacheFile($cache, $this
->compileSource($this
->getLoader()
->getSource($name), $name));
}
require_once $cache;
}
}
if (!$this->runtimeInitialized) {
$this
->initRuntime();
}
return $this->loadedTemplates[$cls] = new $cls($this);
}