Function fmt

Source
pub fn fmt()
Expand description

Formats arguments according to the specified format

The second argument to this filter must be a string literal (as in normal Rust). The two arguments are passed through to the format!() macro by the Askama code generator, but the order is swapped to support filter composition.

{{ value|fmt("{:?}") }}
/// ```jinja
/// <div>{{ value|fmt("{:?}") }}</div>
/// ```
#[derive(Template)]
#[template(ext = "html", in_doc = true)]
struct Example {
    value: (usize, usize),
}

assert_eq!(
    Example { value: (3, 4) }.to_string(),
    "<div>(3, 4)</div>"
);

Compare with format.