– you’re actually putting it in a “Scope.” Scopes hold values in a simple dictionary.
There is a hierarchy of Scopes inside the Context – each Scope has a parent. When a template attempts to retrieve a value, it will look in its most immediate Scope, then work its way up through the ancestor Scopes. It will return the first matching value it finds for the key.
The highest possible Scope is on
TemplateOptions.Scope. This is the common ancestor of all Scopes. Something put here can be considered “global” to all templates, unless “hidden” by a child Scope (keep reading…).
Next down the list is the
LocalScope on a specific Context.
Next down the list are the Scopes on specific templates – every template has its own Scope. Every template gets a Scope, and a new child Scope is created for every template added using an
This means you will always have a minimum of three Scopes – the global, the Context, and whatever template you are executing.
You get another Scope for every
include. If you have a four-step include – A includes B includes C includes D – template D will have a Scope that is six levels down. If you have this in template D: