Generic templating options

I am basically looking for help for googling on how to use templating… There are multiple different templating options, and I often google wrong things. So few basic questions:

  1. How to know which configurations are templatable (e.g. “entity_id:”)?

  2. When templating the line must end with some special character(s), such as >, >-, |, |-. When to use which one?

  3. How to know which templating syntax can/should be used? Such as:

- [[[ return value; ]]]
- {{ value }}
- expression {{ value }}
- {{ value_if_true if (boolean, true) else value_if_false }}
- {% if boolean==true %} value_if_true {% else %} value_if_false {% endif %}

Currently I’m trying to hide an entity in apexchart conditionally and apparently nor stroke_width or in_chart can be templated at all. I guess. In github readme’s there are occasionally some examples on templating, but no list of configurations that can be templated in the first place. It is slightly time consuming to try all different expressions (in question 3) using all different special characters (in question 2). Especially just to conclude that none of them works.

I don’t even know if some of the syntaxes in question 3 are actually the same. Just names for them would help googling (e.g. javascript, CSS, SCSS)

Hi jake,

Some examples and primers to help explain…

One important point is that almost none of the basic core cards allow templating of any kind, so the answer to your “basic questions” may vary from one card to the next, as the developers of custom cards can do pretty much whatever they want.

The only definitive source of truth will be the repository docs provided by the developer.

Those are all block scalar indicators for multiline strings. For the purposes of HA they can pretty much be used interchangeably.

The ones using curly braces are Jinja. This in the template engine used by Home Assistant so it is probably the more common type used in custom cards.

The ones that use triple square brackets are Javascript Templates, most commonly seen in Custom Button card, but there may be other cards out there using them.