Merge remote branch 'hason/template'

* hason/template:
  deleted abstract method doDisplay (maintain BC)
  added possibility to customize "display" in the base template class
This commit is contained in:
Fabien Potencier
2011-04-12 07:53:48 +02:00
6 changed files with 20 additions and 8 deletions
+1 -1
View File
@@ -164,7 +164,7 @@ class Twig_Node_Module extends Twig_Node
protected function compileDisplayHeader(Twig_Compiler $compiler)
{
$compiler
->write("public function display(array \$context, array \$blocks = array())\n", "{\n")
->write("protected function doDisplay(array \$context, array \$blocks = array())\n", "{\n")
->indent()
;
}
+11
View File
@@ -156,6 +156,17 @@ abstract class Twig_Template implements Twig_TemplateInterface
return array_keys($this->blocks);
}
/**
* Displays the template with the given context.
*
* @param array $context An array of parameters to pass to the template
* @param array $blocks An array of blocks to pass to the template
*/
public function display(array $context, array $blocks = array())
{
$this->doDisplay($context, $blocks);
}
/**
* Renders the template with the given context and returns it as string.
*
+2 -1
View File
@@ -34,8 +34,9 @@ interface Twig_TemplateInterface
* Displays the template with the given context.
*
* @param array $context An array of parameters to pass to the template
* @param array $blocks An array of blocks to pass to the template
*/
function display(array $context);
function display(array $context, array $blocks = array());
/**
* Returns the bound environment for this template.
+3 -3
View File
@@ -67,7 +67,7 @@ class Twig_Tests_Node_ModuleTest extends Twig_Tests_Node_TestCase
/* foo.twig */
class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
{
public function display(array \$context, array \$blocks = array())
protected function doDisplay(array \$context, array \$blocks = array())
{
\$context = array_merge(\$this->env->getGlobals(), \$context);
@@ -105,7 +105,7 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
return \$this->parent;
}
public function display(array \$context, array \$blocks = array())
protected function doDisplay(array \$context, array \$blocks = array())
{
\$context = array_merge(\$this->env->getGlobals(), \$context);
@@ -150,7 +150,7 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
return \$this->parent;
}
public function display(array \$context, array \$blocks = array())
protected function doDisplay(array \$context, array \$blocks = array())
{
\$context = array_merge(\$this->env->getGlobals(), \$context);
+2 -2
View File
@@ -65,7 +65,7 @@ class Twig_Tests_Node_SandboxedModuleTest extends Twig_Tests_Node_TestCase
/* foo.twig */
class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
{
public function display(array \$context, array \$blocks = array())
protected function doDisplay(array \$context, array \$blocks = array())
{
\$this->checkSecurity();
\$context = array_merge(\$this->env->getGlobals(), \$context);
@@ -115,7 +115,7 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
return \$this->parent;
}
public function display(array \$context, array \$blocks = array())
protected function doDisplay(array \$context, array \$blocks = array())
{
\$context = array_merge(\$this->env->getGlobals(), \$context);
+1 -1
View File
@@ -91,7 +91,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
class Twig_TemplateTest extends Twig_Template
{
public function display(array $context)
protected function doDisplay(array $context, array $blocks = array())
{
}