Open Matchlighter opened 3 years ago
Lovelace_gen doesn't provide the jinja engine by itself, but instead piggy-backs on the one used by Home Assistant, including all settings for it. I also feel reluctant about adding to or changing a syntax that most hass users are already aware of and (to a varying extent) comfortable with.
The former isn't an issue since you're already creating a separate Jinja Environment strictly for Lovelace Gen, (jinja = jinja2.Environment(loader=jinja2.FileSystemLoader("/"))
) so any custom symbols would be limited only to Lovelace Gen.
What do you think about making this feature optional via a config parameter?
I was thinking about this same sort of thing myself. I might be clever to have the #lovelace_gen
first line in the file carry options to specify the various quoting characters. I think that you can pass in replacements for {{ }}
, {% %}
and {# #}
when the template engine is instantiated.
I've been dealing with a number of usability issues when trying to use Home Assistant
xyz_template
keys in Lovelace. I feel like{% raw %}
and{{ '{{' }}
are very ugly and verbose with as much as I'm trying to use them. I was looking at the Jinja docs and noted the following options on the JinjaEnvironment
object:What are your thoughts on changing those to something else, eg square brackets such as
[[ .. ]]
and[% ... %]
or angle brackets such as<{ ... }>
and<% ... %>
? (Other ideas?)Given that such a change would be a breaking one, I was thinking that it could be added as an option in the
lovelace_gen:
configuration.yaml
entry. For easier entry for new users going forward, I feel like this change should be the default, but that would require action on the part of existing users...I'm more than happy to throw in a PR for this, but wanted to get your thoughts beforehand.