Which scope rules apply to variables defined within nested Pug mixins?
0 reputation · 10 Oct 2022, 12:42 UTC
Pug allows the creation of reusable components through mixins, which can be nested to build complex component hierarchies. While arguments passed to a mixin are locally scoped to that specific block, the behavior of variables declared inside a nested mixin relative to its parent mixin requires clarification.
The goal is to determine if a variable initialized within a child mixin can be accessed by the parent mixin after the child call completes, or if the local scope is strictly destroyed upon the child mixin's termination.
- Does a variable declared inside a nested mixin leak into the parent mixin's scope?
- What is the precise behavior of variable shadowing when a parent and child mixin use the same variable name?