Skip to main content

template_variables

Function template_variables 

Source
pub fn template_variables(
    template: &str,
) -> Result<BTreeSet<String>, RenderError>
Expand description

Enumerate the template variables template requires but never binds itself (e.g. {% for %}/{% set %}-declared names are excluded).

Uses the same Environment configuration as render_system (shared via [build_env], so the two entry points cannot drift apart) and minijinja 2.21’s Template::undeclared_variables(false). A syntax error surfaces here (via template_from_str’s Err) rather than as an empty set — undeclared_variables itself silently returns an empty HashSet when it fails to re-parse the (already-compiled) source, so the syntax check must happen at template_from_str time, before that call.