Sha256: ba0c0859d0f3a889b75823fc4fb9ae0b25d6ac6f355717988d58f76e3028819f

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 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.link_path(@view)}" class="tab">#{tab.text(@view)}</a>}
      else
        html << %Q{<span class="tab">#{tab.text(@view)}</span>}
      end
      html << "</li>"
      html
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tabulous-2.0.0 lib/tabulous/renderers/default_renderer.rb