ui.util.call

Call an inline element as a block element.

This function allows passing complex content into an element using a Jinja2 caller. For example, following simple macro does not contain caller():

{%- call ui.util.call(show_example) -%} {%- raw %} {% macro button(content) %} {% endmacro %} {# You'll get an exception during evaluation of this block: {%- call button() -%}Click{%- endcall %} #} {# It's still ok to make an inline invocation #} {{ button("Click") }} {%- endraw %} {%- endcall %}

Such components cannot be called in form {%- raw -%}{% call ui.button() %}{%- endraw %} and rendering button with nested HTML turns into a verbose task. But using ui.util.call, the button can be used with call

{%- call ui.util.call(show_example) -%} {%- raw %} {% macro button(content) %} {% endmacro %} {% call ui.util.call(button) %} Click! {% endcall %} {%- endraw %} {%- endcall %}

The content of the call block will be passed as a first argument into the target macro. Any other positional and named arguments of the ui.util.call will be redirected into the button macro as well.

{%- call ui.util.call(show_example) -%} {%- raw %} {% macro button(content) %} {% endmacro %} {% call ui.util.call(button, data={"id": "42"}) %} Click! {% endcall %} {%- endraw %} {%- endcall %}

Unless component documentation says otherwise, it's safe to assume that component will cause an exception when used with call directly. Always wrap component calls into ui.util.call.