homeassistant-lovelace-gen icon indicating copy to clipboard operation
homeassistant-lovelace-gen copied to clipboard

Global jinja2 macros

Open Rocka84 opened this issue 6 years ago • 4 comments

Maybe there is a better way for doing something smiliar but this works and was very easy to implement.

Rocka84 avatar Nov 07 '18 20:11 Rocka84

btw: don't be afraid of "+278 lines", most of them are examples :wink:

Rocka84 avatar Nov 07 '18 20:11 Rocka84

I have a change that I'm still experimenting with that allows the jinja import statement to work. Then you can put the macros in a separate file of your choosing and import it as needed.

I'd love to have your examples though, but I don't think the yaml files are necessary. It's better to write a minimal example and put it all in the markdown file.

thomasloven avatar Nov 09 '18 23:11 thomasloven

I'd be happy to ditch this hacky solution if you implement real jinja import! Until then I can live with my fork.

And feel free to use my examples. I added the individual files so that you can easily reuse them for testing.

Rocka84 avatar Nov 10 '18 00:11 Rocka84

Oh. Hi. Thanks for keeping up the work on this!

Two weeks ago, I released lovelace_gen, which is an updated version of this that installas as a custom Home Assistant component and transparently changes the way it parses your ui_lovelace.yaml file. You may want to check that out.

https://github.com/thomasloven/hass-lovelace_gen

It still doesn't have global macros, though...

thomasloven avatar Aug 21 '19 06:08 thomasloven