Sha256: bbce424eb092982e39159f744dae8ec563e18e972cdf126fb6024555af8c4d80

Contents?: true

Size: 1.56 KB

Versions: 12

Compression:

Stored size: 1.56 KB

Contents

module SimpleNavigation
  module Renderer
    
    # This is the base class for all renderers.
    #
    # A renderer is responsible for rendering an ItemContainer (primary or a sub_navigation) and its containing items to HTML.
    # It must be initialized with the current_navigation for the rendered ItemContainer and 
    # optionally with the current_sub_navigation (if the sub_navigation will be nested).
    class Base
      include ActionView::Helpers::UrlHelper
      include ActionView::Helpers::TagHelper
      
      attr_reader :current_navigation, :current_sub_navigation, :controller

      class << self
        
        # Delegates method calls to the controller.
        def controller_method(*methods)
          methods.each do |method|
            delegate method, :to => :controller
          end
        end
        
      end

      controller_method :form_authenticity_token, :protect_against_forgery?, :request_forgery_protection_token
      
      def initialize(current_navigation, current_sub_navigation=nil) #:nodoc:
        @current_navigation = current_navigation
        @current_sub_navigation = current_sub_navigation
        @controller = SimpleNavigation.controller
      end
            
      # Renders the specified ItemContainer to HTML.
      #
      # If <tt>include_sub_navigation</tt> is set to true, the renderer should nest the sub_navigation for the active navigation 
      # inside that navigation item.  
      def render(item_container, include_sub_navigation=false)
        raise 'subclass responsibility'
      end
            
    end
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
andi-simple-navigation-1.2.2 lib/simple_navigation/renderer/base.rb
andi-simple-navigation-1.3.0 lib/simple_navigation/renderer/base.rb
andi-simple-navigation-1.3.1 lib/simple_navigation/renderer/base.rb
andi-simple-navigation-1.4.0 lib/simple_navigation/renderer/base.rb
andi-simple-navigation-1.4.2 lib/simple_navigation/renderer/base.rb
krasivotokak-simple-navigation-1.4.1 lib/simple_navigation/renderer/base.rb
simple-navigation-1.4.2 lib/simple_navigation/renderer/base.rb
simple-navigation-1.4.1 lib/simple_navigation/renderer/base.rb
simple-navigation-1.4.0 lib/simple_navigation/renderer/base.rb
simple-navigation-1.3.0 lib/simple_navigation/renderer/base.rb
simple-navigation-1.3.1 lib/simple_navigation/renderer/base.rb
simple-navigation-1.2.2 lib/simple_navigation/renderer/base.rb