Keats / tera

A template engine for Rust based on Jinja2/Django
http://keats.github.io/tera/
MIT License
3.36k stars 280 forks source link

Use of `(` and `)` to specify order of operations. #910

Closed rukai closed 2 months ago

rukai commented 2 months ago

I came across some code like:

{%- if config.extra.enable_post_view_navigation and page.lower or page.higher %}

I'm pretty sure its broken since config.extra.enable_post_view_navigation and page.lower evaluates first. If tera supported brackets for specifying order of operations I could fix the issue by writing it as:

{%- if config.extra.enable_post_view_navigation and (page.lower or page.higher) %}

As a workaround I was able to solve the issue by writing it as:

    {%- if config.extra.enable_post_view_navigation %}
        {%- if page.lower or page.higher %}

But that is not ideal.

Keats commented 2 months ago

There's https://github.com/Keats/tera/pull/908 for tera v1 and it's already handled correctly in v2

rukai commented 2 months ago

Oh excellent! Sorry for the duplicate issue, it wasn't coming up in my searches.