Module: ContentDriven::Routes

Included in:
Page
Defined in:
lib/content_driven/routes.rb

Instance Method Summary collapse

Instance Method Details

#content_for(route) ⇒ Object

Walks the tree based on a url and returns the requested page Will return nil if the page does not exist



5
6
7
8
9
10
11
# File 'lib/content_driven/routes.rb', line 5

def content_for route
  parts = route.split("/").delete_if &:empty?
  content = parts.inject(self) do |page, part|
    page.children[part.to_sym] if page
  end
  content
end