askama/testing/tests/ui/truncate.rs
René Kijewski 4be302338a generator: do argument coercion for |truncate / |center
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`.
2025-04-21 23:11:24 +02:00

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() {}