mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 02:16:41 +00:00
fixed a regression when a template only extends another one without defining any blocks (closes #683)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
* 1.7.0 (2012-XX-XX)
|
||||
|
||||
* fixed a regression when a template only extends another one without defining any blocks
|
||||
* added compilation checks to avoid misuses of the sandbox tag
|
||||
* fixed filesystem loader freshness logic for high traffic websites
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class Twig_Node_Module extends Twig_Node
|
||||
{
|
||||
$this->compileClassHeader($compiler);
|
||||
|
||||
if (count($this->getNode('blocks')) || count($this->getNode('traits'))) {
|
||||
if (count($this->getNode('blocks')) || count($this->getNode('traits')) || null === $this->getNode('parent') || $this->getNode('parent') instanceof Twig_Node_Expression_Constant) {
|
||||
$this->compileConstructor($compiler);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
"extends" tag
|
||||
--TEMPLATE--
|
||||
{% extends "foo.twig" %}
|
||||
--TEMPLATE(foo.twig)--
|
||||
{% block content %}FOO{% endblock %}
|
||||
--DATA--
|
||||
return array()
|
||||
--EXPECT--
|
||||
FOO
|
||||
@@ -69,6 +69,16 @@ class Twig_Tests_Node_ModuleTest extends Twig_Tests_Node_TestCase
|
||||
/* foo.twig */
|
||||
class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
|
||||
{
|
||||
public function __construct(Twig_Environment \$env)
|
||||
{
|
||||
parent::__construct(\$env);
|
||||
|
||||
\$this->parent = false;
|
||||
|
||||
\$this->blocks = array(
|
||||
);
|
||||
}
|
||||
|
||||
protected function doDisplay(array \$context, array \$blocks = array())
|
||||
{
|
||||
echo "foo";
|
||||
@@ -99,6 +109,16 @@ EOF
|
||||
/* foo.twig */
|
||||
class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
|
||||
{
|
||||
public function __construct(Twig_Environment \$env)
|
||||
{
|
||||
parent::__construct(\$env);
|
||||
|
||||
\$this->parent = \$this->env->loadTemplate("layout.twig");
|
||||
|
||||
\$this->blocks = array(
|
||||
);
|
||||
}
|
||||
|
||||
protected function doGetParent(array \$context)
|
||||
{
|
||||
return "layout.twig";
|
||||
|
||||
@@ -67,6 +67,16 @@ class Twig_Tests_Node_SandboxedModuleTest extends Twig_Tests_Node_TestCase
|
||||
/* foo.twig */
|
||||
class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
|
||||
{
|
||||
public function __construct(Twig_Environment \$env)
|
||||
{
|
||||
parent::__construct(\$env);
|
||||
|
||||
\$this->parent = false;
|
||||
|
||||
\$this->blocks = array(
|
||||
);
|
||||
}
|
||||
|
||||
protected function doDisplay(array \$context, array \$blocks = array())
|
||||
{
|
||||
\$this->checkSecurity();
|
||||
@@ -110,6 +120,16 @@ EOF
|
||||
/* foo.twig */
|
||||
class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template
|
||||
{
|
||||
public function __construct(Twig_Environment \$env)
|
||||
{
|
||||
parent::__construct(\$env);
|
||||
|
||||
\$this->parent = \$this->env->loadTemplate("layout.twig");
|
||||
|
||||
\$this->blocks = array(
|
||||
);
|
||||
}
|
||||
|
||||
protected function doGetParent(array \$context)
|
||||
{
|
||||
return "layout.twig";
|
||||
|
||||
Reference in New Issue
Block a user