pub struct Template {
pub template: String,
pub engine: Option<String>,
pub metadata: HashMap<String, Value>,
}
Expand description
A template definition from a .tomplate.toml
file.
Templates are defined in TOML format with a required template
field
and optional engine
and metadata fields.
§Examples
A typical template definition in TOML:
[my_template]
template = "Hello {name}, welcome to {place}!"
engine = "simple" # Optional
[complex_template]
template = """
{{#if logged_in}}
Welcome back, {{username}}!
{{else}}
Please log in.
{{/if}}
"""
engine = "handlebars"
Fields§
§template: String
The template string containing the template pattern.
This can use various syntaxes depending on the engine:
- Simple:
{variable}
placeholders - Handlebars:
{{variable}}
with full Handlebars features - Tera:
{{ variable }}
with Tera/Jinja2 syntax - MiniJinja: Similar to Tera with Jinja2 syntax
engine: Option<String>
Optional template engine to use.
If not specified, defaults to “simple” or the builder’s default engine. Valid values: “simple”, “handlebars”, “tera”, “minijinja”
metadata: HashMap<String, Value>
Additional metadata for the template.
This can include custom fields for documentation, validation schemas, or any other template-specific information. These fields are preserved but not used by the core template system.
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>,
Deserialize this value from the given Serde deserializer. Read more
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
Mutably borrows from an owned value. Read more