Sha256: 018793af60870a86ead32b9f5f7d411e5c9d2695199728fa18e8254ce6772700

Contents?: true

Size: 826 Bytes

Versions: 5

Compression:

Stored size: 826 Bytes

Contents

# This holds common behavior for all renderer classes.

module Tabulous
  class BaseRenderer

    def initialize(tabset, view)
      @view = view
      @tabset = tabset
    end

    # all renderers need to have a tabs_html method that returns the
    # HTML to be embedded when the <%= tabs %> helper method is called
    def tabs_html
      raise "override me"
    end

  protected

    def tab_html(tab)
      raise "override me"
    end

    def tab_list_html
      html = ''
      for tab in @tabset.primary_tabs
        html << tab_html(tab)
      end
      html
    end

    def tab_url(tab)
      tab.link_path(@view)
    end

    def tab_http_verb_attributes(tab)
      return '' if tab.http_verb == :get
      %Q{data-method="#{tab.http_verb}"}
    end

    def tab_text(tab)
      tab.text(@view)
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tabulous-2.1.4 lib/tabulous/renderers/base_renderer.rb
tabulous-2.1.3 lib/tabulous/renderers/base_renderer.rb
tabulous-2.1.2 lib/tabulous/renderers/base_renderer.rb
tabulous-2.1.1 lib/tabulous/renderers/base_renderer.rb
tabulous-2.1.0 lib/tabulous/renderers/base_renderer.rb