Module: CustomHelper
- Defined in:
- app/helpers/custom_helper.rb
Instance Method Summary collapse
- #render_rating(content) ⇒ Object
- #replace_brakets(title, replacement = '<div class="section_title_line"><span><strong>\1</strong></span></div>') ⇒ Object
Instance Method Details
#render_rating(content) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/custom_helper.rb', line 8 def (content) return content if content.blank? content.gsub(/\[RATING:([\d.]{1,5})\]/) do |matched| rate = matched.gsub(/\[RATING:([\d.]{1,5})\]/, '\1').to_f rate = 5 if rate.nil? stars = (1..5).to_a.map do |v| content_tag :span, '', class: v <= rate ? 'active' : nil end.join('').html_safe content_tag(:div, stars, class: 'rating_block') end end |
#replace_brakets(title, replacement = '<div class="section_title_line"><span><strong>\1</strong></span></div>') ⇒ Object
4 5 6 |
# File 'app/helpers/custom_helper.rb', line 4 def replace_brakets(title, replacement = '<div class="section_title_line"><span><strong>\1</strong></span></div>') title.gsub(/\[(.*?)\]/, replacement) end |