Module: NitroKit::LabelHelper

Defined in:
app/helpers/nitro_kit/label_helper.rb

Instance Method Summary collapse

Instance Method Details

#nk_label(compat_object_name = nil, compat_method = nil, content_or_options = nil, **attrs, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/nitro_kit/label_helper.rb', line 5

def nk_label(compat_object_name = nil, compat_method = nil, content_or_options = nil, **attrs, &block)
  name = field_name(compat_object_name, compat_method)

  case content_or_options
  when String
    text = content_or_options
  when Hash
    text = nil
    attrs.merge!(content_or_options)
  end

  render(Label.from_template(text, for: name, **attrs), &block)
end