Sha256: 02bae0ef6092632985b0ae630b6f8a919bfbd8159c69a1c4614b08c24dcf72ad

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

module SimpleNavigation
  module Renderer

    # This is the base class for all renderers.
    #
    # A renderer is responsible for rendering an ItemContainer and its containing items to HTML.
    class Base
      include ActionView::Helpers::UrlHelper
      include ActionView::Helpers::TagHelper

      attr_reader :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 #:nodoc:
        @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.
      #
      # A renderer should also take the option SimpleNavigation.config.render_all_levels into account. If it is set to true then it should render all navigation levels
      # independent of the <tt>include_sub_navigation</tt> option.
      #
      def render(item_container, include_sub_navigation=false,options={})
        raise 'subclass responsibility'
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
strikeroff-simple-navigation-2.0.2 lib/simple_navigation/renderer/base.rb