Closed
@anentropic

Description

Ideally compile_templates will have deterministic output so we can use git diff etc

See also #1453 and #1452

Found another case where this occurs, e.g. I'm randomly getting these changes or their inverse:

-    context.vars.update({'triage_reports': l_0_triage_reports, 'open_group_index': l_0_open_group_index})
-    context.exported_vars.update(('triage_reports', 'open_group_index'))
+    context.vars.update({'open_group_index': l_0_open_group_index, 'triage_reports': l_0_triage_reports})
+    context.exported_vars.update(('open_group_index', 'triage_reports'))

or:

-                _loop_vars.update({'row_spans': l_2_row_spans, 'row': l_2_row})
+                _loop_vars.update({'row': l_2_row, 'row_spans': l_2_row_spans})

I can see that both of the cases above are a result of using tuple unpacking to set multiple new context vars in a single set call
e.g.

{% set triage_reports, open_group_index = get_nav_list_items(TRIAGE_REPORTS_NAV, url_name, url_func=url) %}
{% set row, row_spans = row %}

The output from compiling the templates should be stable if the underlying template hasn't changed, rather than varying randomly each time you run it.

Environment:

  • Python version: 3.11.5
  • Jinja version: 3.1.4