From e1e9802c562aa4e8f8d5a8d3faaed6f235a38d2f Mon Sep 17 00:00:00 2001
From: Fabien Potencier
{{ text }}
{% endmacro %} + +{{- macros.test('username') }} EOF - ), array('macro'), array('escape')); + ), array('macro', 'import'), array('escape')); $this->assertEquals('username
', $twig->loadTemplate('index')->render(array())); } diff --git a/test/Twig/Tests/Fixtures/expressions/postfix.test b/test/Twig/Tests/Fixtures/expressions/postfix.test index db047c0..542c350 100644 --- a/test/Twig/Tests/Fixtures/expressions/postfix.test +++ b/test/Twig/Tests/Fixtures/expressions/postfix.test @@ -1,6 +1,7 @@ --TEST-- Twig parses postfix expressions --TEMPLATE-- +{% import _self as macros %} {% macro foo() %}foo{% endmacro %} @@ -8,8 +9,8 @@ Twig parses postfix expressions {{ 'a'|upper }} {{ ('a')|upper }} {{ -1|upper }} -{{ _self.foo() }} -{{ (_self).foo() }} +{{ macros.foo() }} +{{ (macros).foo() }} --DATA-- return array(); --EXPECT-- diff --git a/test/Twig/Tests/Fixtures/tags/macro/basic.test b/test/Twig/Tests/Fixtures/tags/macro/basic.test index ef59a57..eef0c10 100644 --- a/test/Twig/Tests/Fixtures/tags/macro/basic.test +++ b/test/Twig/Tests/Fixtures/tags/macro/basic.test @@ -1,8 +1,10 @@ --TEST-- "macro" tag --TEMPLATE-- -{{ _self.input('username') }} -{{ _self.input('password', null, 'password', 1) }} +{% import _self as macros %} + +{{ macros.input('username') }} +{{ macros.input('password', null, 'password', 1) }} {% macro input(name, value, type, size) %} diff --git a/test/Twig/Tests/Fixtures/tags/macro/endmacro_name.test b/test/Twig/Tests/Fixtures/tags/macro/endmacro_name.test index fa81189..ae6203b 100644 --- a/test/Twig/Tests/Fixtures/tags/macro/endmacro_name.test +++ b/test/Twig/Tests/Fixtures/tags/macro/endmacro_name.test @@ -1,8 +1,10 @@ --TEST-- "macro" tag supports name for endmacro --TEMPLATE-- -{{ _self.foo() }} -{{ _self.bar() }} +{% import _self as macros %} + +{{ macros.foo() }} +{{ macros.bar() }} {% macro foo() %}foo{% endmacro %} {% macro bar() %}bar{% endmacro bar %} diff --git a/test/Twig/Tests/Fixtures/tags/macro/special_chars.test b/test/Twig/Tests/Fixtures/tags/macro/special_chars.test index e61716e..0999951 100644 --- a/test/Twig/Tests/Fixtures/tags/macro/special_chars.test +++ b/test/Twig/Tests/Fixtures/tags/macro/special_chars.test @@ -1,7 +1,9 @@ --TEST-- "â" as a macro name --TEMPLATE-- -{{ _self.â('foo') }} +{% import _self as macros %} + +{{ macros.â('foo') }} {% macro â(foo) %} â{{ foo }}â -- 1.7.2.5