* 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
{
$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);
}
--- /dev/null
+--TEST--
+"extends" tag
+--TEMPLATE--
+{% extends "foo.twig" %}
+--TEMPLATE(foo.twig)--
+{% block content %}FOO{% endblock %}
+--DATA--
+return array()
+--EXPECT--
+FOO
/* 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";
/* 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";
/* 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();
/* 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";