I am trying to update variable from an included template in Jinja 2 base.j2: {% set ns = namespace(indent_lvl = 5) %} {% filter indent(width=4*ns.indent_lvl, first=True) %} base_indent_lvl: {{ns.indent_lvl}} {% include template_file with context %} {% endfilter %} template_file.j2: {% set ns.indent_lvl= ns.indent_lvl+1 %} template_indent_lvl: {{ns.indent_lvl}} So ns.indent_lvl increase when it enter in the template but is not save when it returning to base template. Is there a way to do it? Continue reading...