I use Flask with Jinja2 as a template language.
How do you convert a multidimensional Python structure to the corresponding structure in javascript using Jinja2?
Example (Python / Flask):
pyStruct = [{key1:value1, key2:value2, [{subkey1:subvalue1, subkey2:subvalue2,}]},
{key1:value1, key2:value2, [{subkey1:subvalue1, subkey2:subvalue2,}]},]
render_template('jinjatemplate.html', pyStruct=pyStruct)
Example (Jinja2):
??
I suppose I'm asking if this can only be done by creating loop constructs under construction in Jinja2, or am I not seeing a shortcut somewhere?
If the answer is yes, you need to use convoluted loops in Jinja2, then it is probably much easier to just create javascript code directly in python and pass that to Jinja2 for inclusion.
But that seems to defeat the goal of using a template language such as Jinja2, a few ...
I tried (Jinja2):
{{ pyStruct|safe }}
... , unicode Ascii ( ).
, , ? , javascript, .