Sha256: 690ea2d3cdc15fb5cbfb7ec3ad9b5ea9c75951bd4d6c3d161b752dde6ab2bd73

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

require 'active_support/core_ext/string'

module Tabulous
  class DefaultRenderer < SplitRenderer

    def tabs_html
      <<-HTML.strip_heredoc
        <div class="tabs">
          <ul>
            #{ tab_list_html }
          </ul>
        </div>
      HTML
    end

    def subtabs_html
      <<-HTML.strip_heredoc
        <div class="subtabs">
          <ul>
            #{ subtab_list_html }
          </ul>
        </div>
      HTML
    end

  protected

    def tab_html(tab)
      return '' unless tab.visible?(@view)
      html = ''
      klass = ''
      klass << 'active' if tab.active?(@view)
      klass << ' disabled' unless tab.enabled?(@view)
      klass.strip!
      if klass.empty?
        html << '<li>'
      else
        html << %Q{<li class="#{klass}">}
      end
      if tab.clickable?(@view)
        html << %Q{<a href="#{tab_url(tab)}" class="tab" #{tab_http_verb_attributes(tab)}>#{tab_text(tab)}</a>}
      else
        html << %Q{<span class="tab">#{tab_text(tab)}</span>}
      end
      html << "</li>"
      html
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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