Skip to content

Commit

Permalink
Document some limitations on closures
Browse files Browse the repository at this point in the history
Refs #535
  • Loading branch information
mitsuhiko committed Jul 18, 2024
1 parent 527d585 commit 5d6677f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions minijinja/src/vm/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ impl<'template, 'env> State<'template, 'env> {
}

/// Looks up a variable by name in the context.
///
/// # Note on Closures
///
/// Macros and call blocks analyze which variables are referenced and
/// create closures for them. This means that unless a variable is defined
/// as a [global](Environment::add_global) in the environment or it was
/// referenced by a macro, this method won't be able to find it.
#[inline(always)]
pub fn lookup(&self, name: &str) -> Option<Value> {
self.ctx.load(self.env, name)
Expand Down

0 comments on commit 5d6677f

Please sign in to comment.