In jinjia, as shown below, I defined a variable number
{% set number = unit %}
file_dict is a dict type variable. I want to reference the key in file_dict so as to find the value in file_dict where the key is {{number}}
{{file_dict{{number}}}}
It seems that it is illegal to define it like the above, and it cannot be passed.
In addition, macro definition cannot be used either.
{% macro get_value(number) %}
{{ pdf_dict{{number}}}}
{% endmacro %}
Is there any way to define nested variables
I solved it myself. I was reminded that jinjia2 variables have __getitem__ syntax. Just call get directly instead of accessing the attribute. Because after that, instead of calling the variable, I called the string. Wrapping it directly with double brackets would not work. Grammarly