Skip to main content

stage_content_with_template_defaults

Function stage_content_with_template_defaults 

Source
pub fn stage_content_with_template_defaults(
    content_dir: &Path,
    build_dir: &Path,
    template_var_keys: &[String],
) -> Result<PathBuf, Error>
Expand description

Stages a copy of content_dir and injects empty defaults for every {{ var }} reference the templates make.

Works around the staticweaver “Unresolved template tag” crash that fires when user content omits a key their template references — staticdatagen 0.0.10 still calls Engine::new(...) without .with_lax_undefined(true). Tracked at staticdatagen #99.

template_var_keys is the result of collect_template_vars run over the user’s template directory.

Convenience wrapper over stage_content_with_site_defaults with no base URL — no permalink: derivation happens on staged content.

§Errors

Returns io::Error when the staging directory cannot be created or a source file cannot be read or written.