The initial scope of a template is always the metaclass on which it is defined. All standard and extended attributes, collections, and templates defined on the active object metaclass and its parents are visible, but only one object is active at any given time.
| Examples | 
|---|
The following template is applied to a package
                                    P1, which contains a class C1,
                                which contains operations O1 and
                                    O2, which each contain parameters
                                    P1 and P2. The scope changes,
                                affecting the value of the %Name% variable, as each
                                collection is traversed. The Outer keyword is used
                                to return temporarily to previous
                                scopes:%Name%
.foreach_item(Classes)
	\n\t*%Name% in %Outer.Name%
   .foreach_item(Operations)
	   \n\t*%Name% in %Outer.Name% in %Outer.Outer.Name%
      .foreach_item(Parameters)
	      \n\t\t*%Name% in %Outer.Name% in %Outer.Outer.Name% in %Outer.Outer.Outer.Name%
      .next
   .next
.next
Result:P1 *C1 in P1 *O1 in C1 in P1 *P1 in O1 in C1 in P1 *P2 in O1 in C1 in P1 *O2 in C1 in P1 *P1 in O2 in C1 in P1 *P2 in O2 in C1 in P1  | 
The Outer scope is restored when you leave a
                                    .foreach_item block. Nested scopes form a
                                hierarchy that can be viewed as a tree, with the top level scope
                                being the root. Use Parent instead of
                                    Outer to climb above the scope of the original
                                object. For example, nothing will be output if the following
                                template is applied to the parameter
                                P1:%Name% in %Outer.Name% in %Outer.Outer.Name%However, this template will produce output: %Name% in %Parent.Name% in %Parent.Parent.Name%Result: P1 in O1 in C1  |