Test get_value macro
This commit is contained in:
parent
a04cf70655
commit
94ef48fafc
|
|
@ -3,4 +3,6 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% import "_macros.jinja2" as macros %}
|
{% import "_macros.jinja2" as macros %}
|
||||||
GREETING = "{{ macros.greeting('World') }}"
|
|
||||||
|
{% set min_sdk_version = macros.get_value(cookiecutter.pyproject, "tool.flet.android.min_sdk_version") %}
|
||||||
|
min_sdk_version: {{ min_sdk_version }}
|
||||||
|
|
@ -1,8 +1,21 @@
|
||||||
{# _macros.jinja2 #}
|
{# _macros.jinja2 #}
|
||||||
{% macro upper_case(value) %}
|
|
||||||
{{ value.upper() }}
|
|
||||||
{% endmacro %}
|
|
||||||
|
|
||||||
{% macro greeting(name) %}
|
{% macro get_value(dict, path) %}
|
||||||
Hello, {{ name }}!
|
{# Split the path into keys #}
|
||||||
|
{% set keys = path.split('.') %}
|
||||||
|
|
||||||
|
{# Initialize the result with the input dictionary #}
|
||||||
|
{% set result = dict %}
|
||||||
|
|
||||||
|
{# Iterate through the keys and traverse the dictionary #}
|
||||||
|
{% for key in keys %}
|
||||||
|
{% if result is mapping and key in result %}
|
||||||
|
{% set result = result[key] %}
|
||||||
|
{% else %}
|
||||||
|
{% set result = none %}
|
||||||
|
{% break %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{{ result }}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
Loading…
Reference in New Issue