Sha256: b6b0b29adef83b1e999b53359829e7c285cd0d5f4ca120e6a885ed7a73db78e4

Contents?: true

Size: 539 Bytes

Versions: 9

Compression:

Stored size: 539 Bytes

Contents

require "action_view/helpers"

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.10.0 lib/trestle/tab.rb
trestle-0.10.0.pre2 lib/trestle/tab.rb
trestle-0.10.0.pre lib/trestle/tab.rb
trestle-0.9.8 lib/trestle/tab.rb
trestle-0.9.7 lib/trestle/tab.rb
trestle-0.9.6 lib/trestle/tab.rb
trestle-0.9.5 lib/trestle/tab.rb
trestle-0.9.4 lib/trestle/tab.rb
trestle-0.9.3 lib/trestle/tab.rb