Skip to content

Commit

Permalink
Merge pull request #313 from danieldotnl/dict_renderers
Browse files Browse the repository at this point in the history
Fix issue in creating renderers for dictionaries with templates
  • Loading branch information
danieldotnl committed Jan 4, 2024
2 parents e8eec97 + b387c32 commit b522a3e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion custom_components/multiscrape/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def create_renderer(hass, value_template):
"""Create a renderer based on variable_template value."""
"""Create a template renderer based on value_template."""
if value_template is None:
return lambda value: value

Expand All @@ -29,9 +29,12 @@ def _render(value):


def create_dict_renderer(hass, templates_dict):
"""Create template renderers for a dictionary with value_templates."""
if templates_dict is None:
return lambda value: {}

# Create a copy of the templates_dict to avoid modification of the original
templates_dict = templates_dict.copy()
for item in templates_dict:
templates_dict[item] = create_renderer(hass, templates_dict[item])

Expand Down

0 comments on commit b522a3e

Please sign in to comment.