Module: Golden::Theme::Foundation::CommonHelper
- Defined in:
- lib/golden/theme/foundation/common_helper.rb
Instance Method Summary collapse
- #foundation_callback_button(callback_id, options = {}) ⇒ Object
- #foundation_dl_tag(dt = [], dd = [], options = {}) {|dt, dd| ... } ⇒ Object
- #foundation_ul_tag(li = [], options = {}) {|li| ... } ⇒ Object
Instance Method Details
#foundation_callback_button(callback_id, options = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/golden/theme/foundation/common_helper.rb', line 56 def callback_id, = {} = { data: { callback_id: callback_id }, class: 'callback hide' }.deep_merge link_to nil, '', end |
#foundation_dl_tag(dt = [], dd = [], options = {}) {|dt, dd| ... } ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/golden/theme/foundation/common_helper.rb', line 29 def foundation_dl_tag dt = [], dd = [], = {} , dt, dd = dt, [], [] if dt.is_a? Hash or dd.is_a? Hash yield dt, dd if block_given? items = ''.html_safe items << dt if dt.present? dd.each_with_index do |item, index| if item.is_a? Array = item.pop item_content = item.join('').html_safe else = {} item_content = item end item_class = [] item_class << 'first' if index == 0 item_class << 'last' if index == (dd.length - 1) link = item_content.match(/href=(["'])(.*?)(\1)/)[2] rescue nil item_class << 'active' if link and (current_page?(link) rescue false) item_class << .delete(:class) if [:class] dd_class = item_class.empty? ? nil : item_class.join(' ') items << content_tag(:dd, item_content, .merge(class: dd_class) ) end content_tag :dl, items, end |
#foundation_ul_tag(li = [], options = {}) {|li| ... } ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/golden/theme/foundation/common_helper.rb', line 3 def foundation_ul_tag li = [], = {} , li = li, [] if li.is_a? Hash yield li if block_given? items = ''.html_safe li.each_with_index do |item, index| if item.is_a? Array = item.pop item_content = item.join('').html_safe else = {} item_content = item end item_class = [] item_class << 'first' if index == 0 item_class << 'last' if index == (li.length - 1) link = item_content.match(/href=(["'])(.*?)(\1)/)[2] rescue nil item_class << 'current active' if link and (current_page?(link) rescue false) item_class << .delete(:class) if [:class] li_class = item_class.empty? ? nil : item_class.join(' ') items << content_tag(:li, item_content, .merge(class: li_class) ) end content_tag :ul, items, end |