fixed block names unicity

This commit is contained in:
Fabien Potencier
2018-03-20 04:54:27 +01:00
parent 4d9dc79516
commit 6da72c6d8c
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