mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 12:06:56 +00:00
fixed a regression
This commit is contained in:
+9
-1
@@ -334,7 +334,15 @@ class Parser implements \Twig_ParserInterface
|
||||
|
||||
public function getImportedSymbol($type, $alias)
|
||||
{
|
||||
return isset($this->importedSymbols[0][$type][$alias]) ? $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 isset($this->importedSymbols[0][$type][$alias]) ? $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