module ContentDriven::Routes

Public Instance Methods

content_for(route) click to toggle source

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

# 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