Module: Fortitude::Widget::Convenience
- Included in:
- Fortitude::Widget
- Defined in:
- lib/fortitude/widget/convenience.rb
Instance Method Summary collapse
- #add_css_classes(classes_to_add, a = nil, b = nil) ⇒ Object (also: #add_css_class)
- #content_and_attributes_from_tag_arguments(content_or_attributes = nil, attributes = nil) ⇒ Object
Instance Method Details
#add_css_classes(classes_to_add, a = nil, b = nil) ⇒ Object Also known as: add_css_class
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fortitude/widget/convenience.rb', line 14 def add_css_classes(classes_to_add, a = nil, b = nil) classes_to_add = Array(classes_to_add) content, attributes = content_and_attributes_from_tag_arguments(a, b) attributes = if attributes.has_key?('class') attributes.merge('class' => (Array(attributes['class'] || [ ]) + classes_to_add)) else attributes.merge(:class => (Array(attributes[:class] || [ ]) + classes_to_add)) end [ content, attributes ] end |
#content_and_attributes_from_tag_arguments(content_or_attributes = nil, attributes = nil) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fortitude/widget/convenience.rb', line 6 def content_and_attributes_from_tag_arguments(content_or_attributes = nil, attributes = nil) if (! attributes) && content_or_attributes.kind_of?(Hash) [ nil, (content_or_attributes || { }) ] else [ content_or_attributes, (attributes || { }) ] end end |