You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
message: {% raw %}'{{ trigger.payload }}'{% endraw %}
39
+
message: '{{ trigger.payload }}'
39
40
```
41
+
{% endraw %}
40
42
41
43
## {% linkable_title Important Template Rules %}
42
44
43
45
There are a few very important rules to remember when writing automation templates:
44
46
45
-
1. You ***must*** use `data_template` in place of `data` when using templates in the `data` section of a service call.
46
-
1. You ***must*** use `service_template` in place of `service` when using templates in the `service` section of a service call.
47
-
1. You ***must*** surround single-line templates with double quotes (`"`) or single quotes (`'`).
47
+
1. You **must** use `data_template` in place of `data` when using templates in the `data` section of a service call.
48
+
1. You **must** use `service_template` in place of `service` when using templates in the `service` section of a service call.
49
+
1. You **must** surround single-line templates with double quotes (`"`) or single quotes (`'`).
48
50
1. It is advised that you prepare for undefined variables by using `if ... is not none` or the [`default` filter](http://jinja.pocoo.org/docs/dev/templates/#default), or both.
49
51
1. It is advised that when comparing numbers, you convert the number(s) to a [`float`](http://jinja.pocoo.org/docs/dev/templates/#float) or an [`int`](http://jinja.pocoo.org/docs/dev/templates/#int) by using the respective [filter](http://jinja.pocoo.org/docs/dev/templates/#list-of-builtin-filters).
50
52
1. While the [`float`](http://jinja.pocoo.org/docs/dev/templates/#float) and [`int`](http://jinja.pocoo.org/docs/dev/templates/#int) filters do allow a default fallback value if the conversion is unsuccessful, they do not provide the ability to catch undefined variables.
0 commit comments