0.0
No commit activity in last 3 years
No release in over 3 years
A tool that walks through a hash or nested object and applies code to containers and elements based on user defined rules.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

TreeDecorator

TreeDecorator has been designed to make it easier to decorate trees or nested sets of data. The tools provided, walk through a hash or nested object and apply code to containers and elements based on user defined rules.

For an example of how TreeDecorator can be used in Rails:

class Thing < ActiveRecord::Base
  acts_as_nested_set

  def name
    @name
  end
end

hanger = TreeDecorator::ObjectHanger.new(Thing.roots)

hanger.outer   {|content| content_tag('ul', content.html_safe)}
hanger.inner   {|content| content_tag('li', content.html_safe)}
hanger.element {|thing| link_to(thing.name, thing_path(thing))}

hanger.tree  #----> outputs a nested HTML unordered list with each thing's name 
             #      linking to it's default path.

See lib/example and tests for examples of usage