I'd like to conditionally return from a macro, like this pseudocode:
{% macro example() %}
...
{% if condition %} {% return %} {% endif %}
...
{% endmacro %}
Is this possible with Twig, perhaps with a Twig extension?
There's no return in twig, but you can wrap the rest of your macro in an if not condition
block like this:
{% macro example() %}
...
{% if not condition %}
...
{% endif %}
{% endmacro %}
Keep in mind that twig is a templating language.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With