Module: Gluttonberg::Public::HtmlTruncate

Included in:
Gluttonberg::Public
Defined in:
app/helpers/gluttonberg/public/html_truncate.rb

Instance Method Summary collapse

Instance Method Details

#html_truncate(html, truncate_length, options = {}) ⇒ Object

Does NOT behave identical to current Rails truncate method you must pass options as a hash not just values Sample usage: <%= html_truncate(category.description, :length => 120, :omission => “(continued…)” ) -%>…



12
13
14
15
16
17
18
# File 'app/helpers/gluttonberg/public/html_truncate.rb', line 12

def html_truncate(html, truncate_length, options={})
  if html && html.length < truncate_length
    html
  elsif html
    _html_truncate(html, truncate_length, options)
  end
end