Sha256: cbbcee0fba90da82987a50c27df96251c47d33233b9e7da81937d3af30c6d75c
Contents?: true
Size: 635 Bytes
Versions: 1
Compression:
Stored size: 635 Bytes
Contents
# frozen_string_literal: true module CustomHelper def replace_brakets(title, replacement = '<div class="section_title_line"><span><strong>\1</strong></span></div>') title.gsub(/\[(.*?)\]/, replacement) end def render_rating(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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
translation_cms-0.1.5 | app/helpers/custom_helper.rb |