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

- (String?) mark_tag(string, term)

Returns markup a string

Returns:

  • (String, nil)

    markup a string



8
9
10
11
12
13
# 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)
  string.gsub(/(#{t})/i, (:mark, '\1')).html_safe
end