openapi_nexus_typescript/templating/environment.rs
1//! Template environment setup and configuration
2
3use minijinja::Environment;
4
5use super::filters::fmt_filter;
6use super::functions::file_header;
7
8/// Create a new template environment with all filters and functions
9/// Each language generator instance has its own environment
10pub fn create_template_environment() -> Environment<'static> {
11 let mut env = Environment::new();
12 env.set_trim_blocks(true);
13 env.set_lstrip_blocks(true);
14
15 // Load all embedded templates
16 minijinja_embed::load_templates!(&mut env);
17
18 // Format filters
19 env.add_filter("fmt", fmt_filter);
20
21 // Add custom functions
22 env.add_function("file_header", file_header);
23
24 env
25}