Function truncate

Source
pub fn truncate<S: Display>(
    source: S,
    remaining: usize,
) -> Result<TruncateFilter<S>, Infallible>
Expand description

Limit string length, appends ‘…’ if truncated

/// ```jinja
/// <div>{{ example|truncate(2) }}</div>
/// ```
#[derive(Template)]
#[template(ext = "html", in_doc = true)]
struct Example<'a> {
    example: &'a str,
}

assert_eq!(
    Example { example: "hello" }.to_string(),
    "<div>he...</div>"
);