made Twig_Loader::getTemplateName() the only method that knows how to create a template class name

git-svn-id: http://svn.twig-project.org/trunk@127 93ef8e89-cb99-4229-a87c-7fa0fa45744b
This commit is contained in:
fabien
2009-11-11 16:31:21 +00:00
parent 74dbd388dc
commit 688e4bb653
3 changed files with 10 additions and 5 deletions
+5
View File
@@ -243,4 +243,9 @@ class Twig_Compiler implements Twig_CompilerInterface
{
return $this->env;
}
public function getTemplateName($name)
{
return $this->getEnvironment()->getLoader()->getTemplateName($name);
}
}
+2 -2
View File
@@ -41,7 +41,7 @@ class Twig_Node_Import extends Twig_Node
->string($this->macro)
->raw(");\n\n")
->write("if (!class_exists(")
->string('__TwigMacro_'.md5($this->macro))
->string($compiler->getTemplateName($this->macro).'_Macro')
->raw("))\n")
->write("{\n")
->indent()
@@ -50,7 +50,7 @@ class Twig_Node_Import extends Twig_Node
->write("}\n")
->write(sprintf("\$context["))
->string($this->var)
->raw(sprintf("] = new __TwigMacro_%s(\$this->env);\n", md5($this->macro)))
->raw(sprintf("] = new %s_Macro(\$this->env);\n", $compiler->getTemplateName($this->macro)))
;
}
+3 -3
View File
@@ -107,10 +107,10 @@ class Twig_Node_Module extends Twig_Node implements Twig_NodeListInterface
$compiler
->write("/* $this->filename */\n")
->write('class __TwigTemplate_'.md5($this->filename))
->write('class '.$compiler->getTemplateName($this->filename))
;
$parent = null === $this->extends ? $compiler->getEnvironment()->getBaseTemplateClass() : '__TwigTemplate_'.md5($this->extends);
$parent = null === $this->extends ? $compiler->getEnvironment()->getBaseTemplateClass() : $compiler->getTemplateName($this->extends);
$compiler
->raw(" extends $parent\n")
@@ -206,7 +206,7 @@ class Twig_Node_Module extends Twig_Node implements Twig_NodeListInterface
$compiler
->write("\n")
->write('class __TwigMacro_'.md5($this->filename).' extends Twig_Macro'."\n")
->write('class '.$compiler->getTemplateName($this->filename).'_Macro extends Twig_Macro'."\n")
->write("{\n")
->indent()
;