pub struct TemplateLoader { /* private fields */ }Expand description
Service for loading templates with fallback chain support.
Templates are loaded in this order:
- Project-level:
{workspace}/.metis/templates/{type}/{template}.md - Global-level:
~/.config/metis/templates/{type}/{template}.md - Embedded defaults
Implementations§
Source§impl TemplateLoader
impl TemplateLoader
Sourcepub fn new(project_path: Option<PathBuf>) -> Self
pub fn new(project_path: Option<PathBuf>) -> Self
Create a new TemplateLoader with the given project workspace path.
If project_path is None, only global and embedded templates will be used.
Sourcepub fn for_workspace<P: AsRef<Path>>(workspace_dir: P) -> Self
pub fn for_workspace<P: AsRef<Path>>(workspace_dir: P) -> Self
Create a TemplateLoader for a specific workspace directory.
Sourcepub fn load_content_template(
&self,
doc_type: &str,
) -> Result<String, TemplateError>
pub fn load_content_template( &self, doc_type: &str, ) -> Result<String, TemplateError>
Load a content template for the given document type.
Returns the template content string, loading from the first available source in the fallback chain.
Sourcepub fn load_exit_criteria_template(
&self,
doc_type: &str,
) -> Result<String, TemplateError>
pub fn load_exit_criteria_template( &self, doc_type: &str, ) -> Result<String, TemplateError>
Load an exit criteria template for the given document type.
Sourcepub fn validate_template(
&self,
template: &str,
doc_type: &str,
) -> Result<(), TemplateError>
pub fn validate_template( &self, template: &str, doc_type: &str, ) -> Result<(), TemplateError>
Validate a template by rendering it with sample data.
This catches template syntax errors and missing variable references early.
Sourcepub fn sample_context_for_type(&self, doc_type: &str) -> Context
pub fn sample_context_for_type(&self, doc_type: &str) -> Context
Generate sample context values for validating templates.
Each document type gets appropriate sample values for all available variables.
Sourcepub fn has_custom_template(
&self,
doc_type: &str,
template_type: TemplateType,
) -> bool
pub fn has_custom_template( &self, doc_type: &str, template_type: TemplateType, ) -> bool
Check if custom templates exist for a document type.
Sourcepub fn template_source(
&self,
doc_type: &str,
template_type: TemplateType,
) -> TemplateSource
pub fn template_source( &self, doc_type: &str, template_type: TemplateType, ) -> TemplateSource
Get the source of a template (for debugging/info).
Auto Trait Implementations§
impl Freeze for TemplateLoader
impl RefUnwindSafe for TemplateLoader
impl Send for TemplateLoader
impl Sync for TemplateLoader
impl Unpin for TemplateLoader
impl UnsafeUnpin for TemplateLoader
impl UnwindSafe for TemplateLoader
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read more