- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2021 09:06 PM - edited 10-20-2021 03:33 PM
When setting a variable that I want to use else where in a Jinja template, I find it does not seem to work.
For example, the simple script below compares the building name provided in a variable.
{% set building = 'YAB' %}
Building is {{ building }}
{% if 'YAB' == "{{ building }}" %}
Right Building
{% else %}
Wrong Building
{% endif %}
The answer is always Wrong Building, it is as though the if statement cannot read variables, even though my testing statement at the beginning produces the Right building name.
Is there something I am missing regarding using variables?
Solved! Go to Solution.
- Labels:
-
Network Plug-and-Play
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2021 06:34 PM
I worked out the problem (other than being a newbie), the reason this isn't working is because of the brackets I had on the variable.
{% set building = 'YAB' %}
Building is {{ building }}
{% if 'YAB' == building %}
Right Building
{% else %}
Wrong Building
{% endif %}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2021 06:34 PM
I worked out the problem (other than being a newbie), the reason this isn't working is because of the brackets I had on the variable.
{% set building = 'YAB' %}
Building is {{ building }}
{% if 'YAB' == building %}
Right Building
{% else %}
Wrong Building
{% endif %}
