Module: DeadSimpleCMS::Util

Defined in:
lib/dead_simple_cms/util.rb,
lib/dead_simple_cms/util/identifier.rb,
lib/dead_simple_cms/util/identifier/dictionary.rb

Defined Under Namespace

Modules: Identifier

Class Method Summary collapse

Class Method Details

.csserize(str) ⇒ Object

Converts string into css DOM selector for use with class and ID. We currently do lowercase with dashes for cssnames.



5
6
7
8
9
10
11
12
# File 'lib/dead_simple_cms/util.rb', line 5

def self.csserize(str)
  name = str.to_s.dup
  name.gsub!(/[^A-Za-z0-9]+/, " ") # can return nil
  name.gsub!(/(\w)([A-Z])/, '\1-\2') # can return nil
  name.squish!.downcase!
  name.gsub!(" ", "-") # can return nil
  name
end