pub fn render(
path: impl AsRef<Path>,
context: impl IntoContext,
) -> Result<RenderedDocument>Expand description
Load a template from a file and render it in one call.
This wraps Template::from_path and Template::render for the common
case of a template that is rendered once. When the same template is rendered
several times, load it with Template::from_path and call
Template::render on it, because loading is the expensive step.
The context accepts the same values as Template::render: a
crate::Context, a serde_json::Value, or a reference to any
serde::Serialize value.
§Errors
Returns the same errors as Template::from_path and Template::render.
§Examples
let rendered = docx_templating::render(
"template.docx",
serde_json::json!({ "name": "Ada" }),
)?;
rendered.write_to_file("output.docx")?;