mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 11:27:00 +00:00
renamed getTemplateName to getTemplateClass
git-svn-id: http://svn.twig-project.org/trunk@131 93ef8e89-cb99-4229-a87c-7fa0fa45744b
This commit is contained in:
@@ -244,8 +244,8 @@ class Twig_Compiler implements Twig_CompilerInterface
|
||||
return $this->env;
|
||||
}
|
||||
|
||||
public function getTemplateName($name)
|
||||
public function getTemplateClass($name)
|
||||
{
|
||||
return $this->getEnvironment()->getLoader()->getTemplateName($name);
|
||||
return $this->getEnvironment()->getLoader()->getTemplateClass($name);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-2
@@ -59,7 +59,7 @@ abstract class Twig_Loader implements Twig_LoaderInterface
|
||||
*/
|
||||
public function load($name)
|
||||
{
|
||||
$cls = $this->getTemplateName($name);
|
||||
$cls = $this->getTemplateClass($name);
|
||||
|
||||
if (class_exists($cls, false))
|
||||
{
|
||||
@@ -127,7 +127,14 @@ abstract class Twig_Loader implements Twig_LoaderInterface
|
||||
$this->env = $env;
|
||||
}
|
||||
|
||||
public function getTemplateName($name)
|
||||
/**
|
||||
* Gets the template class associated with the given string.
|
||||
*
|
||||
* @param string $name The name for which to calculate the template class name
|
||||
*
|
||||
* @return string The template class name
|
||||
*/
|
||||
public function getTemplateClass($name)
|
||||
{
|
||||
return '__TwigTemplate_'.md5($name);
|
||||
}
|
||||
|
||||
@@ -33,4 +33,13 @@ interface Twig_LoaderInterface
|
||||
* @param Twig_Environment $env A Twig_Environment instance
|
||||
*/
|
||||
public function setEnvironment(Twig_Environment $env);
|
||||
|
||||
/**
|
||||
* Gets the template class associated with the given string.
|
||||
*
|
||||
* @param string $name The name for which to calculate the template class name
|
||||
*
|
||||
* @return string The template class name
|
||||
*/
|
||||
public function getTemplateClass($name);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class Twig_Node_Import extends Twig_Node
|
||||
->string($this->macro)
|
||||
->raw(");\n\n")
|
||||
->write("if (!class_exists(")
|
||||
->string($compiler->getTemplateName($this->macro).'_Macro')
|
||||
->string($compiler->getTemplateClass($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 %s_Macro(\$this->env);\n", $compiler->getTemplateName($this->macro)))
|
||||
->raw(sprintf("] = new %s_Macro(\$this->env);\n", $compiler->getTemplateClass($this->macro)))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,10 +107,10 @@ class Twig_Node_Module extends Twig_Node implements Twig_NodeListInterface
|
||||
|
||||
$compiler
|
||||
->write("/* $this->filename */\n")
|
||||
->write('class '.$compiler->getTemplateName($this->filename))
|
||||
->write('class '.$compiler->getTemplateClass($this->filename))
|
||||
;
|
||||
|
||||
$parent = null === $this->extends ? $compiler->getEnvironment()->getBaseTemplateClass() : $compiler->getTemplateName($this->extends);
|
||||
$parent = null === $this->extends ? $compiler->getEnvironment()->getBaseTemplateClass() : $compiler->getTemplateClass($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 '.$compiler->getTemplateName($this->filename).'_Macro extends Twig_Macro'."\n")
|
||||
->write('class '.$compiler->getTemplateClass($this->filename).'_Macro extends Twig_Macro'."\n")
|
||||
->write("{\n")
|
||||
->indent()
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user