Json

You can serialize json in your template with serde::Serialize


#![allow(unused_variables)]
fn main() {
use serde::Serialize;
#[derive(Template)]
#[template(path = "foo")]
struct Foo<S: Serialize> {
    foo: S
}
}
{{ @json foo }}
{{ @json_pretty foo }}

Don't escape html characters.

If you are looking to paint it as html text (like "Text" in <h1>Text</h1>):

<h1>{{ serde_json::to_string(&foo).map_err(|_| yarte::Error)? }}</h1>