mirror of
https://github.com/gorules/zen.git
synced 2026-10-05 00:02:26 +00:00
* feat: rc variable * feat: implement variable in engine * add exports * fix bindings and improve clone accuracy * fix tests, fix bindings * fix fmt * improve code
19 lines
514 B
Rust
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)
|
|
}
|