Sha256: 3bd8322319658db1bc37b2dbce0c307308883bcebbe517b77b6a1db9464cb559

Contents?: true

Size: 508 Bytes

Versions: 9

Compression:

Stored size: 508 Bytes

Contents

module Trestle
  class Tab
    include ActionView::Helpers::TagHelper

    attr_reader :name, :options

    def initialize(name, options={})
      @name, @options = name, options
    end

    def id(tag=nil)
      ["tab", tag, name].compact.join("-")
    end

    def label
      safe_join([options[:label] || I18n.t("admin.tabs.#{name}", default: name.to_s.titleize), badge].compact, " ")
    end

    def badge
      content_tag(:span, options[:badge], class: "badge") if options[:badge]
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
trestle-0.9.2 lib/trestle/tab.rb
trestle-0.9.1 lib/trestle/tab.rb
trestle-0.9.0 lib/trestle/tab.rb
trestle-0.8.13 lib/trestle/tab.rb
trestle-0.8.12 lib/trestle/tab.rb
trestle-0.8.11 lib/trestle/tab.rb
trestle-0.8.10 lib/trestle/tab.rb
trestle-0.8.9 lib/trestle/tab.rb
trestle-0.8.8 lib/trestle/tab.rb