fixed the "with" behavior to always include the globals

This commit is contained in:
Fabien Potencier
2019-04-10 21:28:27 +02:00
parent 1724e42002
commit 5db545514e
3 changed files with 12 additions and 1 deletions
+1
View File
@@ -1,5 +1,6 @@
* 1.39.0 (2019-XX-XX)
* fixed the "with" behavior to always include the globals (for consistency with the "include" and "embed" tags)
* fixed "include" with "ignore missing" when an error loading occurs in the included template
* added support for a new whitespace trimming option ({%~ ~%}, {{~ ~}}, {#~ ~#})
+1 -1
View File
@@ -58,7 +58,7 @@ class WithNode extends Node
$compiler->write("\$context['_parent'] = \$context;\n");
}
$compiler->write(sprintf("\$context = array_merge(\$context, \$%s);\n", $varsName));
$compiler->write(sprintf("\$context = \$this->env->mergeGlobals(array_merge(\$context, \$%s));\n", $varsName));
} else {
$compiler->write("\$context['_parent'] = \$context;\n");
}
@@ -0,0 +1,10 @@
--TEST--
"with" tag
--TEMPLATE--
{% with [] only %}
{{ global }}
{% endwith %}
--DATA--
return []
--EXPECT--
global