Module: Workbench::HtmlHelper

Defined in:
app/helpers/workbench/html_helper.rb

Overview

Basic, non model dependent helpers that inject HTML, these should all depend on Rails helpers, if they don't they should go into Utilities

Instance Method Summary collapse

Instance Method Details

#mark_tag(string, term) ⇒ String?

Returns markup a string

Returns:

  • (String, nil)

    markup a string



8
9
10
11
12
13
14
15
# File 'app/helpers/workbench/html_helper.rb', line 8

def mark_tag(string, term)
  return nil if string.nil?
  return string if term.nil?
  t = Regexp.escape(term)

  # (?!>) Don't substitute if the next character is a closing paren
  string.gsub(/(#{t})(?!>)/i, (:mark, '\1')).html_safe
end