pub fn render_file_data(data: String, context: &Context) -> Result<String> {
    let mut tera = Tera::default();
    tera.add_raw_template("one_off", &data)?;
    tera.autoescape_on(vec!["html"]);
    tera.register_filter("indent", indent);
    tera.register_filter("as_secret", as_secret);

    // TODO: should be async, but tera needs to expose it
    let result = tera
        .render("one_off", context)
        .chain_err(|| ErrorKind::InvalidOneOffTemplate(data))?;
    let mut xs = vec![];
    for l in result.lines() {
        // trim whitespace (mostly to satisfy linters)
        xs.push(l.trim_end());
    }
    Ok(xs.join("\n"))
}
/// Render convenience function that also trims whitespace
///
/// Takes a template to render either in the service folder or the templates folder.
/// The first takes precendense if it exists.
Render convenience function that also trims whitespace
Takes a template to render either in the service folder or the templates folder.
The first takes precendense if it exists.
Render convenience function that also trims whitespace Takes a template to render either in the service folder or the templates folder . The first takes precendense if it exists .
pub fn render_file_data(data: String, context: &Context) -> Result<String> {
    let mut tera = Tera::default();
    tera.add_raw_template("one_off", &data)?;
    tera.autoescape_on(vec!["html"]);
    tera.register_filter("indent", indent);
    tera.register_filter("as_secret", as_secret);
    // TODO: should be async, but tera needs to expose it
    let result = tera
        .render("one_off", context)
        .chain_err(|| ErrorKind::InvalidOneOffTemplate(data))?;
    let mut xs = vec![];
    for l in result.lines() {
        // trim whitespace (mostly to satisfy linters)
        xs.push(l.trim_end());
    }
    Ok(xs.join("\n"))
}
pub fn render_file_data ( data : String , context : & Context ) -> Result < String > { let mut tera = Tera :: default ( ) ; tera . add_raw_template ( " " , & data ) ? ; tera . autoescape_on ( vec ! [ " " ] ) ; tera . register_filter ( " " , indent ) ; tera . register_filter ( " " , as_secret ) ; // TODO: should be async, but tera needs to expose it let result = tera . render ( " " , context ) . chain_err ( | | ErrorKind :: InvalidOneOffTemplate ( data ) ) ? ; let mut xs = vec ! [ ] ; for l in result . lines ( ) { // trim whitespace (mostly to satisfy linters) xs . push ( l . trim_end ( ) ) ; } Ok ( xs . join ( " \n " ) ) }
Render convenience function that also trims whitespace
Takes a template to render either in the service folder or the templates folder.
Render convenience function that also trims whitespace Takes a template to render either in the service folder or the templates folder .
data
String
context
&Context
data
String
context
&Context