pub fn indent<S, I: AsIndent>(
source: S,
indent: I,
first: bool,
blank: bool,
) -> Result<Indent<S, I>, Infallible>Expand description
Indent lines with spaces or a prefix.
The first line and blank lines are not indented by default.
The filter has two optional bool arguments, first and blank, that can be set to true
to indent the first and blank lines, resp.
§Example of indent with 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>"
);§Example of indent with prefix a custom prefix
/// ```jinja
/// <div>{{ example|indent("$$$ ") }}</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>"
);