March 2019
Intermediate to advanced
412 pages
9h 49m
English
The defaults variable is a tuple of the default values for any keyword arguments the macro explicitly accepts. Let's change our macro to display the default values as well as the arguments:
{% macro test(var_a='a string') -%}
{{ test.arguments }}
{{ test.defaults }}
{%- endmacro -%}
{{ test() }}
Rendering this version of the template will result in the following output:

Here, we can see that the template rendered with both the names, and this time, the default values of the arguments were accepted by the macro.
Read now
Unlock full access