Templates for horizontal stack

Is it possible to use a template in a horizontal stack card to generate other cards?

I have a weekly summary of information that I show in seven markdown cards, each containing a template that formats the raw data. Because each day’s code is similar, I’d like to put it in a loop and generate both the daily content and its markdown card. I would like to put such a template inside a horizontal stack so that an entire week can be displayed across the screen.

I can run the loop in Developer Tools/Template but I’m struggling to get it to work in a Lovelace card and am not even sure if it’s possible. At the moment I repeat the daily 40+ lines of code seven times inside the horizontal stack, which seems very clunky. If there’s a better way to achieve this I’d be really grateful - thanks in advance.

Would this help? It lets you add jinja templates where they could not be added before …

That looks a good possibility, I’ll give it a go! Many thanks.

Another posibility is to generate the text in the backend as a template sensor or something, where you have access to more powerfull tools, and just display the results of that in the markdown cards.

I’m still struggling but probably because I’m new to HA:

I’ve installed lovelace_gen and with

lovelace_gen:

lovelace:

  • mode: yaml*

in configuration.yaml none of my views are displayed and on my home screen I get badges for every sensor HASS can find - with Dark Sky that’s a lot!

The documentation says "any yaml file…must have # lovelace_gen as the first line’ which I assume should include the file that contains the views and cards. I’m on HASS.IO and so far as I can tell the relevant file is /config/.storage/lovelace but including # lovelace_gen as the first line gives an error “Expecting value: line 1 column 1 (char 0)”. Can you point me in the right direction?

Thomas, you also suggest generating the text in the backend as a sensor and I have a couple of questions about this approach:

  • I’m not sure what the more powerful tools you mention would be. I can see that I could move the logic from a card in a view to configuration.yaml but I think for my use case I’d still need to create one sensor per day and as it would be done on the backend I don’t know how to pick up the date and customise accordingly. I’m sure I’m missing something, please can you advise?
  • I think you also have to restart HASS every time you make a change which would make development very tedious

Thanks for your help and sorry for the beginner questions!

You can tell I’m new because I couldn’t format the embedded code correctly - but it was OK in my configuration.yaml!