March 2019
Intermediate to advanced
412 pages
9h 49m
English
The caller variable takes a bit more explaining. A macro can call out to another macro. This can be useful if the same chunk of the template will be used multiple times, but part of the inside changes more than what could easily be passed as a macro parameter. The caller variable isn't exactly a variable; it's more of a reference back to the call to get the contents of that calling macro.
Let's update our template to demonstrate its usage:
{% macro test() -%}The text from the caller follows: {{ caller() }}{%- endmacro -%}{% call test() -%} This is text inside the call {% endcall -%}
The rendered result will be as follows:

A call to ...
Read now
Unlock full access