You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
There seem to be an error with the parsing when writing closures in the templates, for example with the following:
main.rs:
use askama::Template;#[derive(Template)]#[template(path = "hello.html")]structHelloTemplate{names:Vec<String>,}fnmain(){let hello = HelloTemplate{names:vec!["foo".to_string(),"bar".to_string()],};println!("{}", hello.render().unwrap());// then render it.}
hello.html:
{% for name in names.iter().map(|n| n.to_uppercase()) %}
Hello, {{ name }}!
{% endfor %}
I get this error:
error: problems parsing template source at row 1, column 28 near:"(|n| n.to_uppercase()) %}\n Hello, {{ "...
--> src/main.rs:3:10
|
3 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightlybuilds, run with -Z macro-backtrace for more info)
error[E0599]: no method named `render` foundfor struct `HelloTemplate` in the current scope
--> src/main.rs:13:26
|
5 | struct HelloTemplate{
| -------------------- method `render` not found for this
...
13 | println!("{}", hello.render().unwrap());// then render it.
| ^^^^^^ method not found in `HelloTemplate`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `render`, perhaps you need to implement it:
candidate #1: `Template`
For more information about this error, try `rustc --explain E0599`.
error: could not compile `askama-test` due to 2 previous errors
The text was updated successfully, but these errors were encountered:
There seem to be an error with the parsing when writing closures in the templates, for example with the following:
main.rs:
hello.html:
I get this error:
The text was updated successfully, but these errors were encountered: