Function askama::filters::linebreaksbr

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

Converts all newlines in a piece of plain text to HTML line breaks

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

assert_eq!(
    Example { lines: "a\nb\nc" }.to_string(),
    "<div>a<br/>b<br/>c</div>"
);