bug #2664 Fix block names unicity (fabpot)

This PR was merged into the 1.x branch.

Discussion
----------

Fix block names unicity

closes #2658

Commits
-------

6da72c6d fixed block names unicity
This commit is contained in:
Fabien Potencier
2018-03-20 05:05:35 +01:00
2 changed files with 20 additions and 1 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ class Twig_Parser implements Twig_ParserInterface
public function getVarName()
{
return sprintf('__internal_%s', hash('sha256', __METHOD__.$this->varNameSalt++));
return sprintf('__internal_%s', hash('sha256', __METHOD__.$this->stream->getSourceContext()->getCode().$this->varNameSalt++));
}
/**
@@ -0,0 +1,19 @@
--TEST--
Block names are unique per template
--TEMPLATE--
{% extends 'layout' %}
{% block content -%}
{% filter title -%}
second
{% endfilter %}
{% endblock %}
--TEMPLATE(layout)--
{% filter title -%}
first
{% endfilter %}
{% block content %}{% endblock %}
--DATA--
return array();
--EXPECT--
First
Second