Files
zen/core/template/src/lib.rs
T
stefan-gorules 91598166ce feat: rc variable (#246)
* feat: rc variable

* feat: implement variable in engine

* add exports

* fix bindings and improve clone accuracy

* fix tests, fix bindings

* fix fmt

* improve code
2024-09-30 18:34:54 +02:00

19 lines
514 B
Rust

mod error;
mod interpreter;
mod lexer;
mod parser;
use crate::interpreter::Interpreter;
use crate::lexer::Lexer;
use crate::parser::Parser;
use zen_expression::variable::Variable;
pub use crate::error::{ParserError, TemplateRenderError};
pub fn render(template: &str, context: Variable) -> Result<Variable, TemplateRenderError> {
let tokens = Lexer::from(template.trim()).collect();
let nodes = Parser::from(tokens.as_slice()).collect()?;
Interpreter::from(nodes.as_slice()).collect_for(context)
}