module CustomFilters

Extending Liquid filters/text manipulation

Public Instance Methods

commentwrap(input) click to toggle source
# File lib/liquidoc.rb, line 1249
def commentwrap input
  input.wrap commentchar: "# "
end
plainwrap(input) click to toggle source
# File lib/liquidoc.rb, line 1246
def plainwrap input
  input.wrap
end
regexreplace(input, regex, replacement='') click to toggle source
# File lib/liquidoc.rb, line 1267
def regexreplace input, regex, replacement=''
  input.to_s.gsub(Regexp.new(regex), replacement.to_s)
end
slugify(input) click to toggle source
# File lib/liquidoc.rb, line 1259
def slugify input
  # Downcase
  # Turn unwanted chars into the seperator
  s = input.to_s.downcase
  s.gsub!(/[^a-zA-Z0-9\-_\+\/]+/i, "-")
  s
end
unwrap(input) click to toggle source
# File lib/liquidoc.rb, line 1252
def unwrap input # Not fully functional; inserts explicit '\n'
  if input
    token = "[g59hj1k]"
    input.gsub(/\n\n/, token).gsub(/\n/, ' ').gsub(token, "\n\n")
  end
end