lib/nanoc/toolbox/helpers/navigation.rb
def find_item_tree(root, options={})
      return nil unless root.children

      # filter the elements to contain only the kind requested
      children = options[:kind] ? root.children.select { |item| item[:kind] == options[:kind] } : root.children

      # For each child call the find_item_tree on it and then generate the hash
      sections = children.map do |child|
        subsections = find_item_tree(child)

        { :title        => (child[:title] || child.identifier),
          :link         => relative_path_to(child),
          :subsections  => subsections }
      end
    end
# Recursive method that extract from an XPath pattern the document structure
# and return the "permalinks" in a Array of Hash that could be used by the
# rendering method
Recursive method that extract from an XPath pattern the document structure
and return the "permalinks" in a Array of Hash that could be used by the
rendering method
Recursive method that extract from an XPath pattern the document structure and return the " permalinks " in a Array of Hash that could be used by the rendering method
def find_item_tree(root, options={})
      return nil unless root.children
      children = options[:kind] ? root.children.select { |item| item[:kind] == options[:kind] } : root.children
      sections = children.map do |child|
        subsections = find_item_tree(child)
        { :title        => (child[:title] || child.identifier),
          :link         => relative_path_to(child),
          :subsections  => subsections }
      end
    end
def find_item_tree ( root , options = { } ) return nil unless root . children children = options [ :kind ] ? root . children . select { | item | item [ :kind ] == options [ :kind ] } : root . children sections = children . map do | child | subsections = find_item_tree ( child ) { :title => ( child [ :title ] || child . identifier ) , :link => relative_path_to ( child ) , :subsections => subsections } end end
Recursive method that extract from an XPath pattern the document structure
and return the "permalinks" in a Array of Hash that could be used by the
rendering method
Recursive method that extract from an XPath pattern the document structure and return the " permalinks " in a Array of Hash that could be used by the rendering method
# filter the elements to contain only the kind requested # For each child call the find_item_tree on it and then generate the hash
root
options