Module: NokogiriTruncator::TextNode

Includes:
ActionView::Helpers::TextHelper
Defined in:
app/helpers/effective_truncate_html_helper.rb

Instance Method Summary collapse

Instance Method Details

#truncate_html(max_length) ⇒ Object



66
67
68
69
70
71
# File 'app/helpers/effective_truncate_html_helper.rb', line 66

def truncate_html(max_length)
  truncated = truncate(content, length: max_length, separator: ' ', omission: '')

  # Nokogiri::XML::Text.new(truncate(content.to_s, :length => (max_length-1)), parent)
  Nokogiri::XML::Text.new(truncated, parent)
end