From 7a7c23f197482e1c04c70f10b12c2705f358cde6 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 4 Feb 2011 12:46:05 +0100 Subject: [PATCH] added the possibility to pass a readable name for templates --- lib/Twig/Environment.php | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 92809ed..321de23 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -272,12 +272,17 @@ class Twig_Environment /** * Loads a template by name. * - * @param string $name The template name + * @param string $name The template name + * @param string $short The template name to use for error messages * * @return Twig_TemplateInterface A template instance representing the given template name */ - public function loadTemplate($name) + public function loadTemplate($name, $short = null) { + if (null === $short) { + $short = $name; + } + $cls = $this->getTemplateClass($name); if (isset($this->loadedTemplates[$cls])) { @@ -286,10 +291,10 @@ class Twig_Environment if (!class_exists($cls, false)) { if (false === $cache = $this->getCacheFilename($name)) { - eval('?>'.$this->compileSource($this->loader->getSource($name), $name)); + eval('?>'.$this->compileSource($this->loader->getSource($name), $short)); } else { if (!file_exists($cache) || ($this->isAutoReload() && !$this->loader->isFresh($name, filemtime($cache)))) { - $this->writeCacheFile($cache, $this->compileSource($this->loader->getSource($name), $name)); + $this->writeCacheFile($cache, $this->compileSource($this->loader->getSource($name), $short)); } require_once $cache; -- 1.7.2.5