mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 20:16:45 +00:00
fixed a PHP fatal error when calling a macro imported in the template in a nested block
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
* 1.41.1 (2019-XX-XX)
|
* 1.41.1 (2019-XX-XX)
|
||||||
|
|
||||||
|
* fixed a PHP fatal error when calling a macro imported in a block in a nested block
|
||||||
* fixed a PHP fatal error when calling a macro imported in the template in another macro
|
* fixed a PHP fatal error when calling a macro imported in the template in another macro
|
||||||
* fixed wrong error message on "import" and "from"
|
* fixed wrong error message on "import" and "from"
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -335,8 +335,12 @@ class Parser implements \Twig_ParserInterface
|
|||||||
public function getImportedSymbol($type, $alias)
|
public function getImportedSymbol($type, $alias)
|
||||||
{
|
{
|
||||||
if (null !== $this->peekBlockStack()) {
|
if (null !== $this->peekBlockStack()) {
|
||||||
foreach ($this->importedSymbols as $functions) {
|
foreach ($this->importedSymbols as $i => $functions) {
|
||||||
if (isset($functions[$type][$alias])) {
|
if (isset($functions[$type][$alias])) {
|
||||||
|
if (count($this->blockStack) > 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return $functions[$type][$alias];
|
return $functions[$type][$alias];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
--TEST--
|
||||||
|
"macro" tag
|
||||||
|
--TEMPLATE--
|
||||||
|
{% block foo %}
|
||||||
|
{%- from _self import input as linput %}
|
||||||
|
|
||||||
|
{% block bar %}
|
||||||
|
{{- linput('username') }}
|
||||||
|
{% endblock %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% macro input(name) -%}
|
||||||
|
<input name="{{ name }}">
|
||||||
|
{% endmacro %}
|
||||||
|
--DATA--
|
||||||
|
return []
|
||||||
|
--EXCEPTION--
|
||||||
|
Twig\Error\SyntaxError: Unknown "linput" function in "index.twig" at line 6.
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
--TEST--
|
||||||
|
"macro" tag
|
||||||
|
--TEMPLATE--
|
||||||
|
{%- from _self import input %}
|
||||||
|
|
||||||
|
{% block foo %}
|
||||||
|
{% block bar %}
|
||||||
|
{{- input('username') }}
|
||||||
|
{% endblock %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% macro input(name) -%}
|
||||||
|
<input name="{{ name }}">
|
||||||
|
{% endmacro %}
|
||||||
|
--DATA--
|
||||||
|
return []
|
||||||
|
--EXCEPTION--
|
||||||
|
Twig\Error\SyntaxError: Unknown "input" function in "index.twig" at line 6.
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
--TEST--
|
||||||
|
"macro" tag
|
||||||
|
--TEMPLATE--
|
||||||
|
{% block foo %}
|
||||||
|
{%- import _self as lmacros %}
|
||||||
|
|
||||||
|
{% block bar %}
|
||||||
|
{{- lmacros.input('username') }}
|
||||||
|
{% endblock %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% macro input(name) -%}
|
||||||
|
<input name="{{ name }}">
|
||||||
|
{% endmacro %}
|
||||||
|
--DATA--
|
||||||
|
return []
|
||||||
|
--EXPECT--
|
||||||
|
<input name="username">
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
--TEST--
|
||||||
|
"macro" tag
|
||||||
|
--TEMPLATE--
|
||||||
|
{%- import _self as macros %}
|
||||||
|
|
||||||
|
{% block foo %}
|
||||||
|
{% block bar %}
|
||||||
|
{{- macros.input('username') }}
|
||||||
|
{% endblock %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% macro input(name) -%}
|
||||||
|
<input name="{{ name }}">
|
||||||
|
{% endmacro %}
|
||||||
|
--DATA--
|
||||||
|
return []
|
||||||
|
--EXPECT--
|
||||||
|
<input name="username">
|
||||||
Reference in New Issue
Block a user