pub struct Template {
pub id: String,
pub contents: String,
pub group: String,
pub context_mode: ContextMode,
pub structure_mode: StructureMode,
pub extension: String,
pub names: Names,
}
Expand description
A struct representing a fully configured template.
Fields§
§id: String
The template’s id.
This is the file path relative to the templates directory. It serves to identify a template within the registry when rendering.
--> /path/to/templates/nested/template.md
--> nested/template.md
contents: String
The unparsed contents of the template.
This gets parsed and validated during template registration.
group: String
The template’s group name.
See StructureMode::FlatGrouped
and StructureMode::NestedGrouped
for more information.
context_mode: ContextMode
The template’s context mode i.e what the template intends to render.
See ContextMode
for more information.
structure_mode: StructureMode
The template’s structure mode i.e. how the output should be structured.
See StructureMode
for more information.
extension: String
The template’s file extension.
names: Names
The template strings for generating output file and directory names.
Implementations§
Source§impl Template
impl Template
Sourcepub fn new<P>(path: P, string: &str) -> Result<Self>
pub fn new<P>(path: P, string: &str) -> Result<Self>
Creates a new instance of Template
.
§Arguments
path
- The path to the template relative to the templates directory.string
- The contents of the template file.
§Errors
Will return Err
if:
- The template’s opening and closing config tags have syntax errors.
- The tempalte’s config has syntax errors or is missing required fields.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Template
impl<'de> Deserialize<'de> for Template
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Template
impl RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl UnwindSafe for Template
Blanket Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more