Function askama::filters::indent

source ยท
pub fn indent(s: impl Display, width: usize) -> Result<String, Error>
Available on crate feature alloc only.
Expand description

Indent lines with width spaces

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

assert_eq!(
    Example { example: "hello\nfoo\nbar" }.to_string(),
    "<div>hello\n    foo\n    bar</div>"
);