Remove unnecessary repeated definitions of the cleanup macro

This commit is contained in:
2023-07-01 14:08:40 -04:00
parent 1c51c678e5
commit 529b24e310
16 changed files with 152 additions and 315 deletions

View File

@ -177,6 +177,7 @@ sensor:
mdi:calendar-end
{% endif %}
value_template: >
{% from 'formatting.jinja' import cleanup %}
{%- macro getReport() -%}
{% set week = states('sensor.kallen_lunch_menu_week') %}
{% set dow = now().strftime('%A') %}
@ -232,17 +233,7 @@ sensor:
No menu for the current day.
{% endif %}
{%- endmacro -%}
{# a macro that removes all newline characters, empty spaces, and returns formatted text #}
{%- macro cleanup(data) -%}
{%- for item in data.split("\n") if item | trim != "" -%}
{{ item | trim }} {% endfor -%}
{%- endmacro -%}
{# a macro to call all macros :) #}
{%- macro mother_of_all_macros() -%}
{{ getReport() }}
{%- endmacro -%}
{# Call the macro #}
{{- cleanup(mother_of_all_macros()) -}}
{{- cleanup(getReport()) -}}
# - platform: rest