MelleD
June 12, 2023, 5:05pm
1
I have a markdown yaml file to display weather alerts. I would like to display this UI in two views.
Is it possible to outsource the code and reuse it in both views? I would hate to simply copy and paste the code into both views.
Is there any way to directly reference yaml files?
finity
June 12, 2023, 10:04pm
2
yes you can do that using !include
you create a (for example) weather_alerts.yaml and then use “!include weather_alerts.yaml” in the location in the original lovelace config file where you want the markdown card code to show up.
2 Likes
Just an illustration for a good solution provided above:
view_1.yaml:
title: xxx
path: xxx
cards:
- !include my_markdown_card.yaml
- ...
view_2.yaml:
title: yyy
path: yyy
cards:
- !include my_markdown_card.yaml
- ...
my_markdown_card.yaml:
type: markdown
content: ...
If you need to have same card with SOME differences - consider using decluttering-card.
1 Like
MelleD
June 13, 2023, 7:35am
4
Nice thanks I will try that.
MelleD
June 15, 2023, 7:13am
5
I tried it out
- title: Test
path: test
badges: []
cards:
- !include ui_views/dwd.yaml
But cannot parse YAML
YAML kann nicht geparsed werden: YAMLException: unknown tag !<!include> (2898:35) 2895 | - user: be9473fcc99749889470963c43569dec 2896 | badges: [] 2897 | cards: 2898 | - !include ui_views/dwd.yaml --------------------------
Iam in the raw configuration editor
EDIT: okay i think it’s just working with yaml mode, correct?
finity
June 18, 2023, 1:24pm
7
Yeah, sorry. I should have clarified that. I only use yaml mode and completely forget that others use storage mode.
1 Like
MelleD
June 18, 2023, 6:48pm
8
I switched to yaml mode and works very well. Like it more then the UI/Storage mode.
1 Like