mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 15:25:19 +00:00

Don't simply pass any arguments to the filter. The error message won't be useful otherwise. Also ensure that the argument is a `usize`.
25 lines
512 B
Rust
25 lines
512 B
Rust
use askama::Template;
|
|
|
|
#[derive(Template)]
|
|
#[template(source = r#"{{ text | truncate }}"#, ext = "html")]
|
|
struct NoArgument<'a> {
|
|
text: &'a str,
|
|
}
|
|
|
|
#[derive(Template)]
|
|
#[template(source = r#"{{ text | truncate(length) }}"#, ext = "html")]
|
|
struct WrongArgumentType<'a> {
|
|
text: &'a str,
|
|
length: f32,
|
|
}
|
|
|
|
#[derive(Template)]
|
|
#[template(source = r#"{{ text | truncate(length, extra) }}"#, ext = "html")]
|
|
struct TooManyArguments<'a> {
|
|
text: &'a str,
|
|
length: usize,
|
|
extra: bool,
|
|
}
|
|
|
|
fn main() {}
|