zen_tmpl/
lib.rs

1mod error;
2mod interpreter;
3mod lexer;
4mod parser;
5
6use crate::interpreter::Interpreter;
7use crate::lexer::Lexer;
8use crate::parser::Parser;
9use zen_expression::variable::Variable;
10
11pub use crate::error::{ParserError, TemplateRenderError};
12
13pub fn render(template: &str, context: Variable) -> Result<Variable, TemplateRenderError> {
14    let tokens = Lexer::from(template.trim()).collect();
15    let nodes = Parser::from(tokens.as_slice()).collect()?;
16
17    Interpreter::from(nodes.as_slice()).collect_for(context)
18}