Class: Forme::Labeler

Inherits:
Object
  • Object
show all
Defined in:
lib/forme.rb

Overview

Default labeler used by the library, using implicit labels (where the label tag encloses the other tag).

Registered as :default.

Defined Under Namespace

Classes: Explicit

Instance Method Summary collapse

Instance Method Details

#call(tag, input) ⇒ Object

Return a label tag wrapping the given tag. For radio and checkbox inputs, the label occurs directly after the tag, for all other types, the label occurs before the tag.



929
930
931
932
933
934
935
936
937
# File 'lib/forme.rb', line 929

def call(tag, input)
  label = input.opts[:label]
  t = if [:radio, :checkbox].include?(input.type)
    [tag, ' ', label]
  else
    [label, ": ", tag]
  end
  input.tag(:label, {}, t)
end