Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error when using is defined with a filter #1226

Open
ccutrer opened this issue Dec 9, 2024 · 0 comments · May be fixed by #1228
Open

Syntax error when using is defined with a filter #1226

ccutrer opened this issue Dec 9, 2024 · 0 comments · May be fixed by #1228

Comments

@ccutrer
Copy link
Contributor

ccutrer commented Dec 9, 2024

Template:

  {% if value_json.name | first is defined %}a{% else %}b{% endif %}

With binding:

{
  "name": [ "c" ]
}

raises com.hubspot.jinjava.interpret.FatalTemplateErrorsException: Error parsing 'value_json.name | first is defined': syntax error at position 27, encountered 'is', expected '}'

This works in Python Jinja. I can work around with parentheses:

{% if (value_json.name | first) is defined %}a{% else %}b{% endif %}
ccutrer added a commit to ccutrer/zigbee2mqtt that referenced this issue Dec 9, 2024
Jinjava (the Jinja implementation openHAB uses) has an issue with
using `is defined` on a filter (see
HubSpot/jinjava#1226). Using parentheses
works around the issue, and is still compatible with Home Assistant's
reference Python implementation.
ccutrer added a commit to ccutrer/zigbee2mqtt that referenced this issue Dec 9, 2024
Jinjava (the Jinja implementation openHAB uses) has an issue with
using `is defined` on a filter (see
HubSpot/jinjava#1226). Using parentheses
works around the issue, and is still compatible with Home Assistant's
reference Python implementation.
ccutrer added a commit to ccutrer/zigbee2mqtt that referenced this issue Dec 9, 2024
Jinjava (the Jinja implementation openHAB uses) has an issue with
using `is defined` on a filter (see
HubSpot/jinjava#1226). Using parentheses
works around the issue, and is still compatible with Home Assistant's
reference Python implementation.
@jasmith-hs jasmith-hs linked a pull request Dec 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant