Twig 的 tags学习(中文) 之一(4)
{% endmacro %}
{% macro wrapped_input(name, value, type, size) %}
<div class="field">
{{ _self.input(name, value, type, size) }}
</div>
{% endmacro %}
如果两个macro在不同的文件里,你需要使用import
{# forms.html #}
{% macro input(name, value, type, size) %}
<input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" />
{% endmacro %}
{# shortcuts.html #}
{% macro wrapped_input(name, value, type, size) %}
{% import "forms.html" as forms %}
<div class="field">
{{ forms.input(name, value, type, size) }}
</div>
{% endmacro %}
{# forms.html #}
{% macro input(name, value, type, size) %}
<input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" />
{% endmacro %}
{# shortcuts.html #}
{% macro wrapped_input(name, value, type, size) %}
{% import "forms.html" as forms %}
<div class="field">
{{ forms.input(name, value, type, size) }}
</div>
{% endmacro %}
filter标签
就是给整个区块使用过滤器
{% filter upper %}
This text becomes uppercase
{% endfilter %}
{% filter upper %}
This text becomes uppercase
{% endfilter %}
{% filter lower|escape %}
<strong>SOME TEXT</strong>
{% endfilter %}
摘自 jiaochangyun的专栏
相关新闻>>
- 发表评论
-
- 最新评论 更多>>