Sha256: 9955000531926c465051f45511b47e69b46044ab5dc5b4ee4400ccaf1525c973

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

# Create an array of hashes that can be easily fed into SimpleNavigation
# like in the following like:
# https://github.com/andi/simple-navigation/wiki/Dynamic-Navigation-Items
module Navi
  module Renderers
    module SimpleNavigation
      class DynamicItems < Array

        def initialize(template, nav_items, options={})
          @template = template
          @options = options
          nav_items.each do |nav_item|
            self << dynamic_item_for(nav_item)
          end
        end

        private

        def dynamic_item_for(nav_item)
          DynamicItem.new @template, nav_item, @options
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
navi-0.2.1 lib/navi/renderers/simple_navigation/dynamic_items.rb
navi-0.2.0 lib/navi/renderers/simple_navigation/dynamic_items.rb