Module: ListHelper
- Defined in:
- app/helpers/list_helper.rb
Instance Method Summary collapse
- #link_to_list_item(*args, &block) ⇒ Object
- #list(options = {}) ⇒ Object
- #list_item(options = {}) ⇒ Object
- #list_item_label(label = nil) ⇒ Object
- #list_item_value(value = nil) ⇒ Object
- #list_of(items, options = {}, &block) ⇒ Object
Instance Method Details
#link_to_list_item(*args, &block) ⇒ Object
19 20 21 22 23 24 |
# File 'app/helpers/list_helper.rb', line 19 def link_to_list_item(*args, &block) = (args., class: 'list-item') content_tag(:li) do link_to(*args, , &block) end end |
#list(options = {}) ⇒ Object
2 3 4 |
# File 'app/helpers/list_helper.rb', line 2 def list( = {}) component(defaults: { class: 'list' }, options: ) { yield } end |
#list_item(options = {}) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/helpers/list_helper.rb', line 6 def list_item( = {}) = (, class: 'list-item') label = .delete(:label) value = .delete(:value) component(defaults: { class: 'list-item' }) do (list_item_label(label) + list_item_value(value) + (block_given? ? yield : "")).html_safe end end |
#list_item_label(label = nil) ⇒ Object
26 27 28 29 |
# File 'app/helpers/list_helper.rb', line 26 def list_item_label(label = nil) return '' unless label.present? || block_given? content_tag(:span, class: 'list-item-label') { block_given? ? yield : label } end |
#list_item_value(value = nil) ⇒ Object
31 32 33 34 |
# File 'app/helpers/list_helper.rb', line 31 def list_item_value(value = nil) return '' unless value.present? || block_given? content_tag(:span, class: 'list-item-value') { block_given? ? yield : value } end |
#list_of(items, options = {}, &block) ⇒ Object
15 16 17 |
# File 'app/helpers/list_helper.rb', line 15 def list_of(items, = {}, &block) list() { component_items(items, defaults: { class: 'list-item' }, &block) } end |