mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Add is_number as a test for use in select, selectattr, reject, and re… (#63732)
This commit is contained in:
parent
912ff76fda
commit
9c6c13a55c
@ -1939,6 +1939,7 @@ class TemplateEnvironment(ImmutableSandboxedEnvironment):
|
||||
self.globals["unpack"] = struct_unpack
|
||||
self.globals["slugify"] = slugify
|
||||
self.globals["iif"] = iif
|
||||
self.tests["is_number"] = is_number
|
||||
self.tests["match"] = regex_match
|
||||
self.tests["search"] = regex_search
|
||||
|
||||
|
@ -314,6 +314,12 @@ def test_isnumber(hass, value, expected):
|
||||
)
|
||||
== expected
|
||||
)
|
||||
assert (
|
||||
template.Template("{{ value is is_number }}", hass).async_render(
|
||||
{"value": value}
|
||||
)
|
||||
== expected
|
||||
)
|
||||
|
||||
|
||||
def test_rounding_value(hass):
|
||||
|
Loading…
x
Reference in New Issue
Block a user