Files
hassos_config/custom_templates/formatter.jinja
2026-03-26 12:10:21 +01:00

18 lines
445 B
Django/Jinja

{%- macro format_path(hops, path) -%}
{#
usage: {% from 'formatter.jinja' import format_path -%} {{ format_path(hops, path_in ) }}
created by: WJ4IoT, december 2025
#}
{%- if hops > 0 -%}
{%- set ns = namespace(s='') -%}
{%- for i in range(hops) -%}
{%- set b = path[i*2 : i*2 + 2] -%}
{%- set ns.s = ns.s + (('->' if ns.s else '') + b) -%}
{%- endfor -%}
{{ ns.s }}
{%- else -%}
DM
{%- endif -%}
{%- endmacro -%}