This repository has been archived on 2020-05-27. You can view files and clone it, but cannot push or open issues/pull-requests.
tuxbliki/app/helpers/tags_helper.rb

12 lines
316 B
Ruby

module Merb
module TagsHelper
def highlight(text, phrase)
if text.blank? || phrase.blank?
text
else
match = Array(phrase).map { |p| Regexp.escape(p) }.join('|')
text.gsub(/(#{match})/i, '<strong class="highlight">\1</strong>')
end
end
end
end