mustache2 1.0.7

Logic-less templates.
Documentation
//! # Mustache2
//!
//! This is a rewrite of the original mustache crate, which is currently
//! unmaintained.

#![warn(missing_docs)]

/// Data representation used for rendering a template.
pub mod data;
/// Error handling utilities.
pub mod error;
mod lexer;
mod parser;
/// Rendering pipeline for templates.
pub mod render;
mod source;
#[cfg(test)]
mod specs;

pub use data::Data;
#[cfg(feature = "serde")]
pub use data::to_data;
pub use error::Error;

use crate::render::{RenderManager, SourceCache, provider::FsProvider};
use std::path::PathBuf;

/// Render a single Mustache file and return the output. For more control over
/// the rendering process, use [`RenderManager`] instead. [`RenderManager`] also
/// caches templates across multiple render calls, offering a significant
/// performance improvement if you need to batch render multiple files that use
/// the same partials.
pub fn render_once(path: PathBuf, data: Data) -> Result<String, Error> {
    let cache = SourceCache::default();
    let mut renderer = RenderManager::new(FsProvider, &cache);
    renderer.render(path, data)
}