How to make my dynamic varaible more readable?

Hello everyone,

Today i have this dynamic variable:

grp_name: “{%if (environment_true == “someinfo”) and (dialog_vm_role|lower) != (‘someinfo’)%}IM-A-Group{%elif (dialog_vm_role|lower) == (‘bdd’) and (environment_true != “someinfo”)%}IM-A-Group{%elif (dialog_vm_role|lower) == (‘someinfo’) and (environment_true == “someinfo”)%}IM-A-Group; {{ cmd_grp }}IM-A-Group{%endif%}”

It is very long and if i need to modify it later i will be lost in all these conditions,

My question is: Is this possible to clarify and make the variable more readable?
If yes could you help me with the synthax?

Thank you,
Julien.

You can use multiline YAML

grp_name: >
   {% if (environment_true == "someinfo") and (dialog_vm_role|lower) != ('someinfo') %}
   IM-A-Group
   {% elif (dialog_vm_role|lower) == ('bdd') and (environment_true != "someinfo")%}
   IM-A-Group
   {% elif (dialog_vm_role|lower) == ('someinfo') and (environment_true == "someinfo") %}
   IM-A-Group; {{ cmd_grp }}IM-A-Group
   {% endif %}

You might get a new line at the end but that can be mitigated with {%- and/or -%} [1] in the correct places.

[1] http://jinja.pocoo.org/docs/2.10/templates/#whitespace-control

Thanks you a lot for your help,

Best Regards,
Julien.

If someone looking for to eliminate whitespaces, here’s the synthax:

grp_name: >
{% if (First == ‘Hello 1’) and (Second == ‘Hello 3’) -%}
IM-A-Group1
{%- elif (First == ‘Hello 3’) and (Second == ‘Hello 2’) -%}
IM-A-Group2
{%- elif (First == ‘Hello 1’) and (Second == ‘Hello 2’) -%}
IM-A-Group1 and IM-A-Group2
{%- endif %}

All is clear and working for me now :slight_smile: