askama
askama copied to clipboard
Slice syntax inside of template
Is it possible to do quick-and-dirty string slices in a template?
<p class="mb-0">{{ &t.token[0..10] }}</p>
is giving me
error: problems parsing template source at row 16, column 35 near:
"&t.token[0..10] }}</p>\n <"...
--> sparkle-web/src/app/controllers/users/oauth2/index.rs:4:10
|
4 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
t.token.get(0..10).unwrap() would work. The problem is not the slice syntax, actually, but the ampersand is not an operator in Askama.