mitsuhiko / minijinja

MiniJinja is a powerful but minimal dependency template engine for Rust compatible with Jinja/Jinja2
https://docs.rs/minijinja/
Apache License 2.0
1.63k stars 95 forks source link

Cycle error triggered by multiple `include`s of templates that `extend` the same parent template #534

Closed clarkenciel closed 3 months ago

clarkenciel commented 3 months ago

Description

An InvalidOperation error that points to a cycle in template inheritance is triggered when:

Reproduction steps

A reproduction repo can be found here, but here's are some examples of problematic templates:

{% for item in items %}
  {% include "item.html.j2" %}
{% endfor %}

Or even simply:

{% include "item.html.j2" %}
{% include "item.html.j2" %}

Additional helpful information:

What did you expect

Jinja's behavior in these situations (see reproduction repo for evidence) is to allow the multiple includes. It isn't stated explicitly that I can find, but their documentation implies that includes should work in loops in at least one spot.