Jinja2Cpp
Jinja2Cpp copied to clipboard
"for" syntax is not work with dictionary
Hi Admin,
{% for key, value in dict_item.items() %}
Key: {{key}}
Value: {{value}}
{% endfor %}It is not working.
Thanks!
Could you provide more detailed sample of the problem which I can add to C++/Python tests as-is?
This is an example:
nlohmann::json dict_item = {"AD":"376","AE":"971","AF":"93"}; {% for key, value in dict_item.items() %} Key: {{key}} Value: {{value}} {% endfor %}
I see a least one issue here. There is no user-callable 'items' in nlohmann::json reflection. I suppose, you need to replace dict_item.items()
with dict_item
in your sample.
What the result of this sample template processing:
{%set inner_items={"AD":"376","AE":"971","AF":"93"} %}
{% for key, value in inner_items %}
Key: {{key}}
Value: {{value}}
{% endfor %}
it does not work. The result is empty! I think the "for" syntax only works with "array" data.
Ok. Thanks! I'll check it out.