HubSpot / jinjava

Jinja template engine for Java
Apache License 2.0
690 stars 168 forks source link

Only push the block's parent path onto the stack once during execution #1176

Closed jasmith-hs closed 4 months ago

jasmith-hs commented 4 months ago

As I was going to edit some of the logic here for eager execution, I found this redundant logic which pushes and pops the parent path for every node within a block, rather than just doing it once per block.

For instance, if I had a block:

{% block %}
  Hi
  {% if hungry %}
    hungry,
  {% endif %}
  I'm dad!
{% endblock %}

The current logic pushes/pops the parent path for each: Hi, {% if hungry %}, I'm dad!. Instead, we can just do this once outside the for loop.

The logic was originally added in https://github.com/HubSpot/jinjava/pull/363, and there's no need to do it once per node.