pywb icon indicating copy to clipboard operation
pywb copied to clipboard

Enable Expression Statement and Loop Control extensions for Jinja templates

Open despens opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe.

I want to be able to manipulate lists and dictionaries in pywb templates without the result of the action ("None") needing to be printed. This is accomplished with the do tag which needs to be loaded via the Expression Statement extension.

I want to be able to break out of a loop using the break tag, which needs to be loaded via the the Loop Controls extension.

Describe the solution you'd like

pywb should by default load these basic Jinja extensions.

Describe alternatives you've considered

It is possible to suppress the None output of a list manipulation action using a set capture block:

{% set capture_and_forget %}
    {{ mylist.append('🍄') }}
{% endset %}

However, it would be much nicer to just write

{% do mylist.append('🍄') %}

Likewise it is possible to write logic that can skip steps in a loop. But it would be much easier to just use the {% break %} statement.

Additional context

Let's go nice templates! 😉

despens avatar May 09 '23 19:05 despens