pub struct TemplateEngineBuilder { /* private fields */ }Expand description
Comprehensive template engine builder
Provides a fluent API for configuring all aspects of the template engine:
use clnrm_template::TemplateEngineBuilder;
let engine = TemplateEngineBuilder::new()
.with_search_paths(vec!["./templates", "./configs"])
.with_context_defaults()
.with_validation_rules(vec![
ValidationRule::ServiceName,
ValidationRule::Semver,
])
.with_custom_function("my_func", |args| Ok(Value::String("custom".to_string())))
.with_cache(Duration::from_secs(3600))
.with_hot_reload(true)
.build()
.unwrap();Implementations§
Source§impl TemplateEngineBuilder
impl TemplateEngineBuilder
Sourcepub fn with_discovery<F>(self, f: F) -> Self
pub fn with_discovery<F>(self, f: F) -> Self
Configure template discovery
Sourcepub fn with_search_paths<I, P>(self, paths: I) -> Self
pub fn with_search_paths<I, P>(self, paths: I) -> Self
Add search paths for template discovery
Sourcepub fn with_glob_patterns<I, S>(self, patterns: I) -> Self
pub fn with_glob_patterns<I, S>(self, patterns: I) -> Self
Add glob patterns for template discovery
Sourcepub fn with_organization(self, organization: TemplateOrganization) -> Self
pub fn with_organization(self, organization: TemplateOrganization) -> Self
Set template organization strategy
Sourcepub fn with_context<F>(self, f: F) -> Self
pub fn with_context<F>(self, f: F) -> Self
Configure template context
Sourcepub fn with_context_defaults(self) -> Self
pub fn with_context_defaults(self) -> Self
Use default PRD v1.0 context variables
Sourcepub fn with_variables<I, K, V>(self, variables: I) -> Self
pub fn with_variables<I, K, V>(self, variables: I) -> Self
Add context variables
Sourcepub fn with_context_from_file<P: AsRef<Path>>(self, path: P) -> Result<Self>
pub fn with_context_from_file<P: AsRef<Path>>(self, path: P) -> Result<Self>
Load context from file
Sourcepub fn with_validation<F>(self, f: F) -> Self
pub fn with_validation<F>(self, f: F) -> Self
Configure validation
Sourcepub fn with_validation_rules<I>(self, rules: I) -> Selfwhere
I: IntoIterator<Item = ValidationRule>,
pub fn with_validation_rules<I>(self, rules: I) -> Selfwhere
I: IntoIterator<Item = ValidationRule>,
Add validation rules
Sourcepub fn with_validation_format(self, format: OutputFormat) -> Self
pub fn with_validation_format(self, format: OutputFormat) -> Self
Set validation format
Sourcepub fn with_custom_function<F>(self, func: CustomFunction<F>) -> Self
pub fn with_custom_function<F>(self, func: CustomFunction<F>) -> Self
Add custom function
Sourcepub fn with_custom_filter<F>(self, filter: CustomFilter<F>) -> Self
pub fn with_custom_filter<F>(self, filter: CustomFilter<F>) -> Self
Add custom filter
Sourcepub fn with_toml_loader<F>(self, f: F) -> Self
pub fn with_toml_loader<F>(self, f: F) -> Self
Configure TOML loading
Sourcepub fn with_toml_writer<F>(self, f: F) -> Self
pub fn with_toml_writer<F>(self, f: F) -> Self
Configure TOML writing
Sourcepub fn with_toml_merger<F>(self, f: F) -> Self
pub fn with_toml_merger<F>(self, f: F) -> Self
Configure TOML merging
Sourcepub fn with_cache(self, ttl: Duration) -> Self
pub fn with_cache(self, ttl: Duration) -> Self
Configure caching
Sourcepub fn with_cache_and_reload(self, ttl: Duration, hot_reload: bool) -> Self
pub fn with_cache_and_reload(self, ttl: Duration, hot_reload: bool) -> Self
Configure caching with hot-reload
Sourcepub fn without_cache(self) -> Self
pub fn without_cache(self) -> Self
Disable caching
Sourcepub fn with_output_format(self, format: OutputFormat) -> Self
pub fn with_output_format(self, format: OutputFormat) -> Self
Set output format
Sourcepub fn with_debug(self, debug: bool) -> Self
pub fn with_debug(self, debug: bool) -> Self
Enable debug mode
Sourcepub fn build(self) -> Result<TemplateLoader>
pub fn build(self) -> Result<TemplateLoader>
Build the template engine configuration
Returns a configured template loader that can be used for rendering
Sourcepub fn build_cached(self) -> Result<CachedRenderer>
pub fn build_cached(self) -> Result<CachedRenderer>
Build cached renderer for performance
Sourcepub async fn build_async_cached(self) -> Result<AsyncTemplateRenderer>
pub async fn build_async_cached(self) -> Result<AsyncTemplateRenderer>
Build async cached renderer (if async feature is enabled)
Sourcepub fn build_complete(self) -> Result<TemplateEngine>
pub fn build_complete(self) -> Result<TemplateEngine>
Build complete template engine with all components
Returns a struct containing all configured components for advanced usage