我理解这个概念,但我不懂语法.
我将使用他们网站上使用的示例
{% macro render_dialog(title, class='dialog') -%}
<div class="{{ class }}">
<h2>{{ title }}</h2>
<div class="contents">
{{ caller() }}
</div>
</div>
{%- endmacro %}
{% call render_dialog('Hello World') %}
This is a simple dialog rendered by using a macro and
a call block.
{% endcall %}
Run Code Online (Sandbox Code Playgroud)
什么是输出?
子问题(因为我对如何工作很困惑):你是否允许每个宏只有1个来电?
Mar*_*riy 12
这是输出:
<div class="dialog">
<h2>Hello World</h2>
<div class="contents">
This is a simple dialog rendered by using a macro and
a call block.
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
因此,当我们调用render_dialog时,我们将'Hello World'作为标题caller()传递,当它到达时它会传递call块的内容.
| 归档时间: |
|
| 查看次数: |
3258 次 |
| 最近记录: |