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

`if` statement with parens fails to parse #882

Closed tinct-martini closed 1 month ago

tinct-martini commented 7 months ago

The following fails to parse with tera but works fine with jinja2:

{% if (brand.id == "barfoo") or (brand.id == "foobar") %}LOL{% endif %}

with the following error:

Tera error: Error { kind: Msg("Failed to parse 'test.html'"), source: Some(Error { kind: Msg(" --> 1:17\n  |\n1 | {% if (brand.id == \"barfoo\") or (brand.id == \"foobar\") %}LOL{% endif %}\n  |                 ^---\n  |\n  = expected `+`, `-`, `*`, `/`, or `%`"), source: None }) }

Changing the template to something more reasonable also fails with the exact same error:

{% if (brand.id == "barfoo" or brand.id == "foobar") %}LOL{% endif %}

I know the first example is a bit silly and you're not aiming for 100% jinja compatibility but do you think this could be fixed?

Thanks in advance!

Keats commented 7 months ago

I've just added a test in the next version for that (https://github.com/Keats/tera2/commit/c5dc6c9b5cfad6ae54ecc4a6f4bfc58641e29e3f) and it works

tinct-martini commented 7 months ago

Do you have a rough timeline for when we can expect terra2? Are we talking days, weeks or months? 😄

Keats commented 7 months ago

Definitely closer to months. A beta release will be tested for quite some time in Zola before actually releasing v2 proper

jeremija commented 2 months ago

@Keats I just created a PR that should fix the issue, I'd greatly appreciate if you could have a look: https://github.com/Keats/tera/pull/908 :pray: