Ternary conditional for tera set or macro

Is there a ternary conditional that might be used to set a value
ie.

{% set mylength = config.extra.content_length is defined ? config.extra.content_length : 200;

opposed to the if else double set

{% if config.extra.content_length is defined %}
{% set mylength = config.extra.content_length
{% else %}
{% set mylength = 200
{%end%}

alternatively, theres the following in the tera assignment suggesting some ability to set from a macro.

{% set my_var = macros::some_macro() %}

how would that function ?

{% macro set_ternary(condition, value_true, value_false) %}
    {% if condition %}
        value_true
    {% else %}
        value_false
    {% endif %}
{% endmacro set_ternary %}
1 Like

Not currently but I’ve added them to Tera v2 last week: Ternary (#31) · Keats/tera2@e8577ab · GitHub

3 Likes