mirror of
https://github.com/gorules/zen.git
synced 2026-10-06 08:02:18 +00:00
* feat: expression static analysis * fix: cargo fmt * fix: python workflow * fix: python workflow * fix: python workflow * fix: ignore miri test bound by clock * fix: memory leaks
21 lines
539 B
Rust
21 lines
539 B
Rust
#![forbid(unsafe_code)]
|
|
|
|
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)
|
|
}
|