Jinja2 : including multiple templates, and sharing variables between them -
fellow jinja2 lovers,
i'm migrating templating language jinja2. want convert existing templates as possible without change in structure, i'm running issues.
i have 1 parent file, contains user input, , main text print. have 4 files include, each contain logic, , "should" declare , assign values variables based on logic. :
- parent (declares e, , uses a, b, c, d, , prints output)
- child1 (declares a, uses e)
- child2 (declares b, uses , e)
- child3 (declares c, uses a, b e)
- child4 (declares d, uses a, b, c, , e)
now, context passing, can print in child templates values entered users (the "e"). logic applied properly, , inside child, print shows variable ("a", "b", "c", or "d") assigned right value. once parent template, jinja2 prints empty string these variables. context isn't modified @ (i understand after googling expected ?).
so did next logical thing (as doc , google didn't help), declared variables ("a", "b", ...) inside parent, again, context isn't changed. tried append value variables (now list), still no joy.
so, there way me achieve using jinja2 ? been googling around, no joy.
petzi
ps: maybe important parent file child of file, , on ... original templates organized ooo tree
Comments
Post a Comment