#[non_exhaustive]pub struct CompileOptions<'a> {
pub allow_unused: bool,
pub base_dir: Option<&'a Path>,
pub env: &'a [(&'a str, Value)],
}Expand description
Configuration for template compilation.
Collects all optional parameters that previously required separate
constructor functions. Use with Template::compile or
Template::compile_file.
§Examples
use md_tmpl_core::CompileOptions;
// Default options (strict mode):
let opts = CompileOptions::default();
// Allow unused declared parameters:
let opts = CompileOptions::default().allow_unused(true);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.allow_unused: boolWhen true, declared parameters that are never referenced in the
template body are allowed instead of producing an error.
Equivalent to allow_unused: true in frontmatter.
base_dir: Option<&'a Path>Base directory for resolving {% include %} and {% import %} directives.
When None, includes are not resolved (suitable for in-memory templates).
env: &'a [(&'a str, Value)]Compile-time environment variables (name-value pairs).
Values are typed — they must match the type declared in env: frontmatter.
String values for scalar types (int, bool, float) are auto-parsed.
Implementations§
Source§impl<'a> CompileOptions<'a>
impl<'a> CompileOptions<'a>
Sourcepub fn base_dir(self, dir: &'a Path) -> CompileOptions<'a>
pub fn base_dir(self, dir: &'a Path) -> CompileOptions<'a>
Set the base directory for include resolution.
Source§impl<'a> CompileOptions<'a>
impl<'a> CompileOptions<'a>
Sourcepub fn allow_unused(self, allow: bool) -> CompileOptions<'a>
pub fn allow_unused(self, allow: bool) -> CompileOptions<'a>
Allow unused declared parameters.
Sourcepub fn env(self, pairs: &'a [(&'a str, Value)]) -> CompileOptions<'a>
pub fn env(self, pairs: &'a [(&'a str, Value)]) -> CompileOptions<'a>
Set compile-time environment variables.
Trait Implementations§
Source§impl<'a> Clone for CompileOptions<'a>
impl<'a> Clone for CompileOptions<'a>
Source§fn clone(&self) -> CompileOptions<'a>
fn clone(&self) -> CompileOptions<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more