{# _macros.jinja2 #} {% macro get_value(dict, path) %} {# Split the path into keys #} {% set keys = path.split('.') %} {# Initialize the result with the input dictionary #} {% set result = dict %} {# Use a flag to detect when to stop processing #} {% set valid = true %} {# Iterate through the keys and traverse the dictionary #} {% for key in keys %} {% if valid and result is mapping and key in result %} {% set result = result[key] %} {% else %} {% set result = none %} {% set valid = false %} {% endif %} {% endfor %} {{ result }} {% endmacro %}