TemplateEngineBuilder

Struct TemplateEngineBuilder 

Source
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

Source

pub fn new() -> Self

Create new template engine builder

Source

pub fn with_discovery<F>(self, f: F) -> Self

Configure template discovery

Source

pub fn with_search_paths<I, P>(self, paths: I) -> Self
where I: IntoIterator<Item = P>, P: AsRef<Path>,

Add search paths for template discovery

Source

pub fn with_glob_patterns<I, S>(self, patterns: I) -> Self
where I: IntoIterator<Item = S>, S: AsRef<str>,

Add glob patterns for template discovery

Source

pub fn with_organization(self, organization: TemplateOrganization) -> Self

Set template organization strategy

Source

pub fn with_context<F>(self, f: F) -> Self

Configure template context

Source

pub fn with_context_defaults(self) -> Self

Use default PRD v1.0 context variables

Source

pub fn with_variables<I, K, V>(self, variables: I) -> Self
where I: IntoIterator<Item = (K, V)>, K: Into<String>, V: Into<Value>,

Add context variables

Source

pub fn with_context_from_file<P: AsRef<Path>>(self, path: P) -> Result<Self>

Load context from file

Source

pub fn with_validation<F>(self, f: F) -> Self

Configure validation

Source

pub fn with_validation_rules<I>(self, rules: I) -> Self
where I: IntoIterator<Item = ValidationRule>,

Add validation rules

Source

pub fn with_validation_format(self, format: OutputFormat) -> Self

Set validation format

Source

pub fn with_custom_function<F>(self, func: CustomFunction<F>) -> Self
where F: Fn(&HashMap<String, Value>) -> Result<Value> + Send + Sync + 'static,

Add custom function

Source

pub fn with_custom_filter<F>(self, filter: CustomFilter<F>) -> Self
where F: Fn(&Value, &HashMap<String, Value>) -> Result<Value> + Send + Sync + 'static,

Add custom filter

Source

pub fn with_toml_loader<F>(self, f: F) -> Self

Configure TOML loading

Source

pub fn with_toml_writer<F>(self, f: F) -> Self

Configure TOML writing

Source

pub fn with_toml_merger<F>(self, f: F) -> Self

Configure TOML merging

Source

pub fn with_cache(self, ttl: Duration) -> Self

Configure caching

Source

pub fn with_cache_and_reload(self, ttl: Duration, hot_reload: bool) -> Self

Configure caching with hot-reload

Source

pub fn without_cache(self) -> Self

Disable caching

Source

pub fn with_output_format(self, format: OutputFormat) -> Self

Set output format

Source

pub fn with_debug(self, debug: bool) -> Self

Enable debug mode

Source

pub fn build(self) -> Result<TemplateLoader>

Build the template engine configuration

Returns a configured template loader that can be used for rendering

Source

pub fn build_cached(self) -> Result<CachedRenderer>

Build cached renderer for performance

Source

pub async fn build_async_cached(self) -> Result<AsyncTemplateRenderer>

Build async cached renderer (if async feature is enabled)

Source

pub fn build_complete(self) -> Result<TemplateEngine>

Build complete template engine with all components

Returns a struct containing all configured components for advanced usage

Trait Implementations§

Source§

impl Default for TemplateEngineBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Fake for T

Source§

fn fake<U>(&self) -> U
where Self: FakeBase<U>,

Source§

fn fake_with_rng<U, R>(&self, rng: &mut R) -> U
where R: Rng + ?Sized, Self: FakeBase<U>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V