Module: PostsHelper

Defined in:
app/helpers/posts_helper.rb

Instance Method Summary collapse

Instance Method Details

#try_highlight(text, options = {}) ⇒ Object



2
3
4
5
6
7
8
9
# File 'app/helpers/posts_helper.rb', line 2

def try_highlight(text, options = {})
  options[:length] ||= 100

  e = excerpt(text, params[:q].strip, radius: options[:length]) ||
    truncate(text, length: options[:length])

  highlight(e, params[:q])
end