mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-01 13:07:22 +00:00
Merge branch '1.x' into 2.x
* 1.x: fixed a regression
This commit is contained in:
+9
-1
@@ -279,7 +279,15 @@ class Parser
|
||||
|
||||
public function getImportedSymbol($type, $alias)
|
||||
{
|
||||
return $this->importedSymbols[0][$type][$alias] ?? null;
|
||||
if (null !== $this->peekBlockStack()) {
|
||||
foreach ($this->importedSymbols as $functions) {
|
||||
if (isset($functions[$type][$alias])) {
|
||||
return $functions[$type][$alias];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return $this->importedSymbols[0][$type][$alias] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
public function isMainScope()
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
"macro" tag
|
||||
--TEMPLATE--
|
||||
{% block foo %}
|
||||
{%- from _self import input as linput %}
|
||||
{% endblock %}
|
||||
|
||||
{% block bar %}
|
||||
{{- linput('username') }}
|
||||
{% endblock %}
|
||||
|
||||
{% macro input(name) -%}
|
||||
<input name="{{ name }}">
|
||||
{% endmacro %}
|
||||
--DATA--
|
||||
return []
|
||||
--EXCEPTION--
|
||||
Twig\Error\SyntaxError: Unknown "linput" function in "index.twig" at line 7.
|
||||
@@ -0,0 +1,36 @@
|
||||
--TEST--
|
||||
"macro" tag
|
||||
--TEMPLATE--
|
||||
{% import _self as macros %}
|
||||
{% from _self import input %}
|
||||
|
||||
{% block foo %}
|
||||
{{- macros.input('username') }}
|
||||
{{- input('username') }}
|
||||
|
||||
{%- import _self as lmacros %}
|
||||
{%- from _self import input as linput %}
|
||||
|
||||
{{- lmacros.input('username') }}
|
||||
{{- linput('username') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block bar %}
|
||||
{{- macros.input('username') }}
|
||||
{{- input('username') }}
|
||||
{% endblock %}
|
||||
|
||||
{% macro input(name) -%}
|
||||
<input name="{{ name }}">
|
||||
{% endmacro %}
|
||||
--DATA--
|
||||
return []
|
||||
--EXPECT--
|
||||
<input name="username">
|
||||
<input name="username">
|
||||
<input name="username">
|
||||
<input name="username">
|
||||
|
||||
|
||||
<input name="username">
|
||||
<input name="username">
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
"macro" tag
|
||||
--TEMPLATE--
|
||||
{% block foo %}
|
||||
{%- import _self as lmacros %}
|
||||
{% endblock %}
|
||||
|
||||
{% block bar %}
|
||||
{{- lmacros.input('username') }}
|
||||
{% endblock %}
|
||||
|
||||
{% macro input(name) -%}
|
||||
<input name="{{ name }}">
|
||||
{% endmacro %}
|
||||
--DATA--
|
||||
return []
|
||||
--EXCEPTION--
|
||||
Twig\Error\RuntimeError: Variable "lmacros" does not exist in "index.twig" at line 7.
|
||||
Reference in New Issue
Block a user