use std::collections::BTreeMap;

use crate::{Escaper, Templates};

pub mod value;
pub use value::Value;

mod error;
pub use error::Error;
pub(crate) use error::WRONG_TYPE_MESSAGE;

mod context;
pub(crate) use context::write_tmpl;

pub(crate) fn tmpl_output<Esc: Escaper>(
    tmpls: &Templates<Esc>,
    index: usize,
    args: BTreeMap<String, Value>,
) -> Result<String, Error> {
    let mut result = String::new();

    write_tmpl(&mut result, tmpls, index, args)?;

    Ok(result)
}
