Module: Nanoc::Helpers::Text
- Defined in:
- lib/nanoc/helpers/text.rb
Overview
Instance Method Summary collapse
Instance Method Details
#excerptize(string, length: 25, omission: '...') ⇒ String
11 12 13 14 15 16 17 18 |
# File 'lib/nanoc/helpers/text.rb', line 11 def excerptize(string, length: 25, omission: '...') if string.length > length excerpt_length = [0, length - omission.length].max string[0...excerpt_length] + omission else string end end |
#strip_html(string) ⇒ String
23 24 25 26 |
# File 'lib/nanoc/helpers/text.rb', line 23 def strip_html(string) # FIXME: will need something more sophisticated than this, because it sucks string.gsub(/<[^>]*(>+|\s*\z)/m, '').strip end |