Class: ExpressTemplates::Components::TreeFor

Inherits:
Container show all
Defined in:
lib/express_templates/components/tree_for.rb

Overview

Create an html table or ol (ordered list) for a model object representing a tree of similar objects.

The objects must respond to :children.

The block is passed a NodeBuilder which may accept field names.

Example:

“‘ruby tree_for(:roles) do |role|

role.name

end “‘

If the view has an @roles variable with a Role having children, this will turn into markup such as the following:

<ul id="roles" class="roles tree">
  <li>SuperAdmin
    <ul>
      <li>Admin</li>
        <ul>
          <li>Publisher</li>
            <ul>
               <li>Author</li>
            </ul>
          <li>Auditor</li>
        </ol>
      </li>
    </ol>
  </li>
</ol>

Instance Attribute Summary

Attributes inherited from Expander

#handlers, #locals, #stack

Method Summary

Methods included from Capabilities::Parenting

included

Methods inherited from Base

inherited

Methods included from Capabilities::Iterating

included

Methods included from Capabilities::Wrapping

included

Methods included from Capabilities::Rendering

included

Methods included from Capabilities::Templating

included

Methods included from Macro

included

Methods inherited from Expander

#expand, #initialize, #initialize_expander, #method_missing, #process_children!, register_macros_for

Constructor Details

This class inherits a constructor from ExpressTemplates::Expander

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ExpressTemplates::Expander