Open dkebler opened 4 years ago
I'd still be interested in alternative template engines but I did figure out how to iterate the keys/values of a object hash in jinja
# lovelace_gen
{% set zones = { '1':'Front North', '2':'Front South', '3':'Front Beds'} %}
icon: mdi:water
cards:
- type: vertical-stack
cards:
- type: markdown
content: >
# Irrigation
- type: horizontal-stack
cards:
{% for zone,name in zones.items() %}
- type: entity-button
entity: switch.irrigation_zone_{{ zone }}
icon: mdi:water
name: {{ name }}
tap_action:
action: toggle
{% endfor %}
First of all...excellent and super useful component for groups of related entities like my bank of irrigation solenoids, thx.
Being a nodejs coder and pretty much a noob at python I'm finding jinja2 painful.
I understand the backend of HA is python but that shouldn't mean that lovelace can't support template engines using another language? Javascript for example...aaahh. If so how hard would that be to include others?
i.e. one of these https://colorlib.com/wp/top-templating-engines-for-javascript/
Jade/Pug is a good one and there is a maintained python package for that. https://pypi.org/project/pypugjs/
In the meantime can you give me a little jinja2 help?
I have this working
but I want to use a hash but can't find any jinga2 examples to help out and of have no idea how python does object hash.