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

Templating: Jinja 2 vs Jinja 3 vs HomeAssistant #31276

Closed
MacDada opened this issue Feb 6, 2024 · 3 comments
Closed

Templating: Jinja 2 vs Jinja 3 vs HomeAssistant #31276

MacDada opened this issue Feb 6, 2024 · 3 comments

Comments

@MacDada
Copy link
Contributor

MacDada commented Feb 6, 2024

Feedback

The problem

According to the docs, the templating engine is based upon Jinja 2:

Templating in Home Assistant is powered by the Jinja2 templating engine.

The problem is, that the links target the latest Jinja docs, which currently describe Jinja v3 (not v2), for example:

While the float and int filters do allow a default fallback value if the conversion is unsuccessful, they do not provide the ability to catch undefined variables.

The link to v3 docs, while erroneously labeled as for v2, is also provided by the Developer Tools -> Template panel of HA:

Screenshot 2024-02-06 at 19 31 58

Possible solutions

a.) Easier: change links to the latest 2.x branch of docs: https://jinja.palletsprojects.com/en/latest/templates/#float -> https://jinja.palletsprojects.com/en/2.11.x/templates/
b.) Harder: upgrade HA's Jinja engine to be based upon v3

I can help with option a.).

URL

https://www.home-assistant.io/docs/configuration/templating

Version

2024.1.6

Additional information

No response

@frenck
Copy link
Member

frenck commented Feb 6, 2024

Harder: upgrade HA's Jinja engine to be based upon v3

We use Jinja2 v3 (please note, it is Jinja2 engine, which is currently at version 3; there is no Jinja3 engine).

So nothing to upgrade there.

@MacDada
Copy link
Contributor Author

MacDada commented Feb 6, 2024

please note, it is Jinja2 engine, which is currently at version 3; there is no Jinja3 engine

wow, that's a mess xD
1 2

@MacDada MacDada closed this as not planned Won't fix, can't repro, duplicate, stale Feb 6, 2024
@frenck
Copy link
Member

frenck commented Feb 6, 2024

Haha lol xD

@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants