tera icon indicating copy to clipboard operation
tera copied to clipboard

`if` statement with parens fails to parse

Open tinct-martini opened this issue 1 year ago • 4 comments

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!

tinct-martini avatar Dec 13 '23 19:12 tinct-martini

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

Keats avatar Dec 13 '23 19:12 Keats

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

tinct-martini avatar Dec 13 '23 19:12 tinct-martini

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

Keats avatar Dec 13 '23 20:12 Keats

@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:

jeremija avatar Apr 30 '24 09:04 jeremija