WTH can't we use a more powerful templating language like ERB?

I’ve been very busy recently with a complete rewrite of most of my HA config and I’ve gotten so tired of Jinja2 that I need to write this topic.

In the python world Jinja2 is the de facto standard, but it pales in comparison to Ruby’s ERB. The latter being a templating engine that can evaluate raw ruby code and supports template partials (imaging being able to pass variables to a template :slight_smile: ). It would make using templates so much more powerful and enjoyable.
I wouldn’t mind a templating engine that can evaluate raw python code – anything to get rid of jinja2 – but AFAIK that’s not really a thing?

I know it won’t be a popular suggestion in a pthon project, but if we could have a Ruby API and template renderer that would be great. For the Ruby API: it’s very easy to directly call python code from ruby, so that shouldn’t be a big effort :wink:

Maybe this will be more your style:


You can do this with jinja templates.

You can do this just about everywhere templates are allowed. I’m curious what you actually mean with this phrase. Do you have an example?

My mistake, that part was a bit ignorant regarding jinja. The core of my suggestion is about having the power of a full programming language in templates. It’s very much comparable with ESPHome where one can add straightforward C++ lambdas instead of having to juggle with a pseudo-language.

1 Like

There’s pyscript (python), appdaemon (python), netdaemon (C#).

I posted this some while ago Global template variables

and that would be what poster here asks? global variables per template: sensor, and not having to declare those per individual template inside those.

Using the this variable comes somewhat close, but its not as powerful just yet

So yes, a big +1 for that request.

btw @clayhill you should vote :wink:

and no, still not complaining…