Class: Forme::Wrapper::TableRow
- Inherits:
-
Forme::Wrapper
- Object
- Forme::Wrapper
- Forme::Wrapper::TableRow
- Defined in:
- lib/forme/transformers/wrapper.rb
Instance Method Summary collapse
-
#call(tag, input) ⇒ Object
Wrap the input in tr and td tags.
Instance Method Details
#call(tag, input) ⇒ Object
Wrap the input in tr and td tags.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/forme/transformers/wrapper.rb', line 31 def call(tag, input) a = super.flatten labels, other = a.partition{|e| e.is_a?(Tag) && e.type.to_s == 'label'} if labels.length == 1 ltd = labels rtd = other elsif a.length == 1 ltd = [a.first] rtd = a[1..-1] else ltd = a end input.tag(:tr, input.opts[:wrapper_attr], [input.tag(:td, {}, ltd), input.tag(:td, {}, rtd)]) end |