The Green Shoes Manual 1.1.362

Traversing the Page

You may find yourself needing to loop through the elements inside a slot. Or maybe you need to climb the page, looking for a stack that is the parent of an element.

On any element, you may call the parent method to get the slot directly above it. And on slots, you can call the contents method to get all of the children. (Some elements, such as shapes, are not included in any slots.)

contents() » an array of elements

Lists all elements in a slot.

parent() » a Shoes::Stack or Shoes::Flow

Gets the object for this element's container.

 Shoes.app do
   s = stack do
     para 'Green'
     @p = para 'Shoes'
   end
   para s
   para s.contents
   para @p.parent
 end

Next: Elements