Scopes are the building blocks of the templating system. They define the range in which variables, expressions, and functions are valid and accessible.
The global scope is the highest-level scope. It is defined by the function sets currently used. Some function sets are available anytime, while others must be invoked before they can be used. Global scopes can overlap, and they do not form a hierarchy among themselves.
The currently defined scope, created by the chosen function sets, determines which functions can be used to create smaller, nested scopes in the template. Each nested scope can contain additional variables, expressions, and functions, and may itself contain further nested scopes.
Variables, expressions, and functions defined inside a nested scope cannot be accessed outside of that scope. However, variables, expressions, and functions from outer scopes remain accessible inside the nested scopes. This ensures that each scope is self-contained, while still allowing information to flow downward into the nested scopes.