module StaticMatic::Helpers::UrlHelper

Public Instance Methods

urlify(string) click to toggle source

Generates a URL friendly string from the value passed:

“We love Haml” -> “we_love_haml” “Elf & Ham” -> “elf_and_ham” “Stephen's gem” -> “stephens_gem”

# File lib/staticmatic/helpers/url_helper.rb, line 48
def urlify(string)
  string.tr(" ", "_").
         sub("&", "and").
         sub("@", "at").
         tr("^A-Za-z0-9_", "").
         sub(/_{2,}/, "_").
         downcase
end