mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-19 15:26:59 +00:00
Fix the links to float and int data types on the Jinja project website (#39325)
This commit is contained in:
parent
9c4011b644
commit
87bce7b424
@ -52,8 +52,8 @@ There are a few very important rules to remember when adding templates to YAML:
|
|||||||
|
|
||||||
1. You **must** surround single-line templates with double quotes (`"`) or single quotes (`'`).
|
1. You **must** surround single-line templates with double quotes (`"`) or single quotes (`'`).
|
||||||
2. It is advised that you prepare for undefined variables by using `if ... is not none` or the [`default` filter](https://jinja.palletsprojects.com/en/latest/templates/#jinja-filters.default), or both.
|
2. It is advised that you prepare for undefined variables by using `if ... is not none` or the [`default` filter](https://jinja.palletsprojects.com/en/latest/templates/#jinja-filters.default), or both.
|
||||||
3. It is advised that when comparing numbers, you convert the number(s) to a [`float`](https://jinja.palletsprojects.com/en/latest/templates/#float) or an [`int`](https://jinja.palletsprojects.com/en/latest/templates/#int) by using the respective [filter](https://jinja.palletsprojects.com/en/latest/templates/#list-of-builtin-filters).
|
3. It is advised that when comparing numbers, you convert the number(s) to a [`float`](https://jinja.palletsprojects.com/en/latest/templates/#jinja-filters.float) or an [`int`](https://jinja.palletsprojects.com/en/latest/templates/#jinja-filters.int) by using the respective [filter](https://jinja.palletsprojects.com/en/latest/templates/#list-of-builtin-filters).
|
||||||
4. While the [`float`](https://jinja.palletsprojects.com/en/latest/templates/#float) and [`int`](https://jinja.palletsprojects.com/en/latest/templates/#int) filters do allow a default fallback value if the conversion is unsuccessful, they do not provide the ability to catch undefined variables.
|
4. While the [`float`](https://jinja.palletsprojects.com/en/latest/templates/#jinja-filters.float) and [`int`](https://jinja.palletsprojects.com/en/latest/templates/#jinja-filters.int) filters do allow a default fallback value if the conversion is unsuccessful, they do not provide the ability to catch undefined variables.
|
||||||
|
|
||||||
Remembering these simple rules will help save you from many headaches and endless hours of frustration when using automation templates.
|
Remembering these simple rules will help save you from many headaches and endless hours of frustration when using automation templates.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user