catch_varargs

Much like catch_kwargs, this variable exists if the macro accesses the varargs variable. Modifying our example once more, we can see this in action:

{% macro test() -%} 
{{ varargs }} 
{{ test.catch_varargs }} 
{%- endmacro -%} 
{{ test('surprise') }}

The template's rendered result will be as follows:

Again, we can see that we were able to catch and render the unexpected value that was passed to the macro, rather than returning an error on render, as would have happened if we hadn't used catch_varargs.

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

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