defaults

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.12.140