I've racked my brain in all directions but still no solution. Maybe someone has some advice?
I have the following block in an ExpressJS app using Nunjucks as the templating engine.
{%- for course in courses -%}
{%- for rcourse in report.courses -%}
{%- if rcourse.id == course.id -%}
<li {{ 'class="column-pre"' if loop.last else ''}}><span>Cool!</span></li>
{%- else -%}
<li></li>
{%- endif -%}
{%- endfor -%}
{%- endfor -%}
My problem: I need to break the inner report.courses loop when the conditional proves truth-y. Basically, the moment that I print the non-empty <li> line, I need to jump to the next iteration of the courses loop.
I know that Nunjucks does't have a break for loops like Jinja2, Nunjucks' variables are scoped (so I can't set a sentinel-like variable that gets modified in the if/else statement), nor can I append to an array so that I can use array.length as a way to determine if I should print the <li></li> line.
Maybe someone has a clever solution?