Using card templates¶
A card template stores a complete reusable card design. You define the common card once and create individual cards by supplying only the entities and settings that differ.
This page shows how to define a user template, use it in a card, reuse shared color stops, and keep system and personal templates organized separately.
Create a card template¶
A card template is useful when several complete cards share the same structure and only a few supplied values differ.
Choose what the template supplies¶
template.type tells the card which block in the template is reused. The block name must match the type.
template.type | Matching block | What it supplies |
|---|---|---|
card | card: | A complete card configuration. |
color_stops | color_stops: | A reusable color-stop configuration. |
state_map | state_map: | A reusable state mapping. |
The same mechanism also applies to another template body whose block name matches template.type.
Use the template for a card¶
Once a template exists, a card can reuse it and provide only the values that are different for that card.
The instance contains only the values that make this card different.
Override values from the template¶
Values written where the template is used take precedence over the values supplied by the template. Nested mappings are combined, so you can override only one setting inside a larger block. Lists are replaced by the list supplied at the use site rather than appended to the template list.
You can use the short form when no variables are needed:
Use the object form when you also pass variables:
Give variables default values¶
Defaults make a variable optional for a card instance. In the example above, name, min, and max already have defaults.
See Template variables for lists and configuration blocks.
Reuse color stops as a template¶
Color-stop templates keep the same value-to-color meaning consistent across several cards or tools.
Use it with:
Keep system and user templates separate¶
Use fhs_sys_templates for distributed templates and fhs_user_templates for your own templates.
If the same template name exists in more than one catalog, a template defined for the current view is found before a dashboard-level template. At the same level, fhs_user_templates is checked before fhs_sys_templates.