pub fn linebreaks<S: Display>(
source: S,
) -> Result<HtmlSafeOutput<NewlineCounting<S>>, Infallible>Expand description
Replaces line breaks in plain text with appropriate HTML.
A single newline becomes an HTML line break <br> and a new line
followed by a blank line becomes a paragraph break <p>.
/// ```jinja
/// <div>{{ example|linebreaks }}</div>
/// ```
#[derive(Template)]
#[template(ext = "html", in_doc = true)]
struct Example<'a> {
example: &'a str,
}
assert_eq!(
Example { example: "Foo\nBar\n\nBaz" }.to_string(),
"<div><p>Foo<br/>Bar</p><p>Baz</p></div>"
);