#Card Templating

1 messages · Page 1 of 1 (latest)

coral pine
#

I found the custom:decluttering-card as well as [some references to it in the old chat](#frontend-archived message).

Is this still the best way to template cards that don't have it built in? For example, I want to template my custom:webrtc-camera card but it doesn't offer a built-in way to do so.

Prior to adding in the decluttering card, I wanted to see if there was a a built-in or more recommended way. Thank you!

GitHub

🧹 Declutter your lovelace configuration with the help of this card - custom-cards/decluttering-card

mental charm
#

AFAIK, the only options are the Decluttering card, custom:button-card, and using YAML anchors.
The custom:button-card has its own internal configuration templating capability. Another unique feature of the custom:button-card is that you can embed other cards into it. It can be a hassle but useful. In theory, you could put your webrtc-camera cards inside a custom:button-card.
YAML anchors can only be used on a dashboard set to YAML Mode. You can't use the UI on this dashboard. Instead, you would use your preferred text/code editor and do all of the dashboard setup in plain text. I'd suggest setting up a dual-configuration where you can use the UI to help you with some that you can copy into the YAML Mode dashboard. Adding More Dashboards with YAML. A bonus to YAML Mode is being able to use !includes which allows you to link to other files with code. This can make things more organized.
I've posted one of my dashboards where you can see YAML anchors, !includes`, and custom:button-card templates. Mini-PC

coral pine
#

Hey @mental charm, appreciate the detailed response, pretty much exactly I was wondering.

I've used a couple of the custom:button-card templates for buttons only, but hadn't considered putting other cards inside it... I think I will probably shy away from that route for now since that seems like a bit of a confusing anti-pattern, even if it is possible.

I ended up adding the custom:decluttering-card and it seems to do pretty much everything I want with the exception of rending expression templates for some conditional stuff I was trying to do.

I'll have to look into the YAML mode dashboards more closely since that seems to be the closest thing to templating but without the UI configuration aspect and it would get me more comfortable with YAML anyway. Cheers.