Module: ShowFor::Label

Included in:
Builder
Defined in:
lib/show_for/label.rb

Instance Method Summary collapse

Instance Method Details

#label(text_or_attribute, options = {}, apply_options = true) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/show_for/label.rb', line 3

def label(text_or_attribute, options={}, apply_options=true)
  label = if text_or_attribute.is_a?(String)
    text_or_attribute
  elsif options.key?(:label)
    options.delete(:label)
  else
    human_attribute_name(text_or_attribute)
  end

  return ''.html_safe if label == false
  options[:label_html] = options.dup if apply_options

  label = ShowFor.label_proc.call(label) if options.fetch(:wrap_label, true) && ShowFor.label_proc
  wrap_with :label, label, options
end