module Nanoc::Helpers::Text

@see nanoc.app/doc/reference/helpers/#text

Public Instance Methods

excerptize(string, length: 25, omission: '...') click to toggle source

@param [String] string @param [Number] length @param [String] omission

@return [String]

# 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) click to toggle source

@param [String] string

@return [String]

# 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