Trim white-space

This commit is contained in:
Feodor Fitsner 2025-02-26 17:13:42 -08:00
parent 938ebcc6f2
commit 889886112e
1 changed files with 10 additions and 10 deletions

View File

@ -1,16 +1,16 @@
{# _macros.jinja2 #}
{% macro get_value(dict, path) %}
{% macro get_value(dict, path) -%}
{# Split the path into keys #}
{% set keys = path.split('.') %}
{% if keys and dict is mapping and keys[0] in dict %}
{% if keys and dict is mapping and keys[0] in dict -%}
{% set next_value = dict[keys[0]] %}
{% if keys | length == 1 %}
{{ next_value }}
{% else %}
{{ get_value(next_value, keys[1:] | join('.')) }}
{% endif %}
{% else %}
{% if keys | length == 1 -%}
{{ next_value | string | trim }}
{%- else -%}
{{ get_value(next_value, keys[1:] | join('.')) | string | trim }}
{%- endif %}
{%- else -%}
{{ none }}
{% endif %}
{% endmacro %}
{%- endif %}
{%- endmacro %}