Document how to return 'no value' from a lambda filter (#2761)

* Document how to filter out values in a lambda filter

* Fix the code example
This commit is contained in:
Sybren A. Stüvel 2023-03-18 22:39:41 +01:00 committed by GitHub
parent 58454811ae
commit 437a19218f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -493,6 +493,16 @@ the result of the lambda is used as the output (use ``return``).
Make sure to add ``.0`` to all values in the lambda, otherwise divisions of integers will
result in integers (not floating point values).
To prevent values from being published, return ``{}``:
.. code-block:: yaml
filters:
- lambda: !lambda |-
if (x < 10) return {};
return x-10;
Example: Converting Celsius to Fahrenheit
-----------------------------------------