mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 12:26:30 +00:00
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:
@@ -243,4 +243,9 @@ class Twig_Compiler implements Twig_CompilerInterface
|
||||
{
|
||||
return $this->env;
|
||||
}
|
||||
|
||||
public function getTemplateName($name)
|
||||
{
|
||||
return $this->getEnvironment()->getLoader()->getTemplateName($name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user