Keats / tera

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

Cannot compile `throw` #836

Closed KoltesDigital closed 1 year ago

KoltesDigital commented 1 year ago

Hi. I can't get the right syntax to compile. Can you?

{% throw(message="Error") %}

Result:

Error { kind: Msg("Failed to parse '__tera_one_off'"), source: Some(Error { kind: Msg(" --> 1:1\n  |\n1 | {% throw(message=\"Error\") %}␍␊\n  | ^---\n  |\n  = expected a template"), source: None }) }
Keats commented 1 year ago

Try {{ throw(message="Error") }}

KoltesDigital commented 1 year ago
Error { kind: Msg("Failed to render '__tera_one_off'"), source: Some(Error { kind: CallFunction("throw"), source: Some(Error { kind: Msg("Err"), source: None }) }) }

Note that I'm actually using tera-cli, which use tera 1.18.

KoltesDigital commented 1 year ago

Ah nevermind, that was the good one. Wrapped in {% if 0 %} {% endif %} it doesn't fail anymore, so that's the expected result. Thanks!