mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
Add ord() to template filters (#25398)
* Add ord() to template filters * Remove trailing whitespace * add test
This commit is contained in:
parent
ea5d3ce85a
commit
3512d05467
@ -857,6 +857,7 @@ class TemplateEnvironment(ImmutableSandboxedEnvironment):
|
|||||||
self.filters['regex_findall_index'] = regex_findall_index
|
self.filters['regex_findall_index'] = regex_findall_index
|
||||||
self.filters['bitwise_and'] = bitwise_and
|
self.filters['bitwise_and'] = bitwise_and
|
||||||
self.filters['bitwise_or'] = bitwise_or
|
self.filters['bitwise_or'] = bitwise_or
|
||||||
|
self.filters['ord'] = ord
|
||||||
self.globals['log'] = logarithm
|
self.globals['log'] = logarithm
|
||||||
self.globals['sin'] = sine
|
self.globals['sin'] = sine
|
||||||
self.globals['cos'] = cosine
|
self.globals['cos'] = cosine
|
||||||
|
@ -388,6 +388,12 @@ def test_max(hass):
|
|||||||
hass).async_render() == '3'
|
hass).async_render() == '3'
|
||||||
|
|
||||||
|
|
||||||
|
def test_ord(hass):
|
||||||
|
"""Test the ord filter."""
|
||||||
|
assert template.Template('{{ "d" | ord }}',
|
||||||
|
hass).async_render() == '100'
|
||||||
|
|
||||||
|
|
||||||
def test_base64_encode(hass):
|
def test_base64_encode(hass):
|
||||||
"""Test the base64_encode filter."""
|
"""Test the base64_encode filter."""
|
||||||
assert template.Template('{{ "homeassistant" | base64_encode }}',
|
assert template.Template('{{ "homeassistant" | base64_encode }}',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user