From: fabien Date: Wed, 11 Nov 2009 16:31:21 +0000 (+0000) Subject: made Twig_Loader::getTemplateName() the only method that knows how to create a templa... X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=688e4bb65355f534a18f8de0b314dd215aa4988c;p=konrad%2Ftwig.git 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 --- diff --git a/lib/Twig/Compiler.php b/lib/Twig/Compiler.php index 95d7f00..936c5f5 100644 --- a/lib/Twig/Compiler.php +++ b/lib/Twig/Compiler.php @@ -243,4 +243,9 @@ class Twig_Compiler implements Twig_CompilerInterface { return $this->env; } + + public function getTemplateName($name) + { + return $this->getEnvironment()->getLoader()->getTemplateName($name); + } } diff --git a/lib/Twig/Node/Import.php b/lib/Twig/Node/Import.php index e0b0dc9..2614084 100644 --- a/lib/Twig/Node/Import.php +++ b/lib/Twig/Node/Import.php @@ -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))) ; } diff --git a/lib/Twig/Node/Module.php b/lib/Twig/Node/Module.php index 5212d07..36adfc5 100644 --- a/lib/Twig/Node/Module.php +++ b/lib/Twig/Node/Module.php @@ -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() ;