mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
Detect comments in jinja templates (#39496)
This commit is contained in:
parent
00eb23b43f
commit
190611a079
@ -52,7 +52,7 @@ _RE_GET_ENTITIES = re.compile(
|
||||
re.I | re.M,
|
||||
)
|
||||
|
||||
_RE_JINJA_DELIMITERS = re.compile(r"\{%|\{\{")
|
||||
_RE_JINJA_DELIMITERS = re.compile(r"\{%|\{\{|\{#")
|
||||
|
||||
_RESERVED_NAMES = {"contextfunction", "evalcontextfunction", "environmentfunction"}
|
||||
|
||||
|
@ -2279,3 +2279,12 @@ async def test_cache_garbage_collection():
|
||||
assert not template._NO_HASS_ENV.template_cache.get(
|
||||
template_string
|
||||
) # pylint: disable=protected-access
|
||||
|
||||
|
||||
def test_is_template_string():
|
||||
"""Test is template string."""
|
||||
assert template.is_template_string("{{ x }}") is True
|
||||
assert template.is_template_string("{% if x == 2 %}1{% else %}0{%end if %}") is True
|
||||
assert template.is_template_string("{# a comment #} Hey") is True
|
||||
assert template.is_template_string("1") is False
|
||||
assert template.is_template_string("Some Text") is False
|
||||
|
Loading…
x
Reference in New Issue
Block a user