Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/locomotive/core_ext.rb

Overview

String

Instance Method Summary collapse

Instance Method Details


16
17
18
19
20
21
22
23
24
25
# File 'lib/locomotive/core_ext.rb', line 16

def permalink(underscore = false)
  # if the slug includes one "_" at least, we consider that the "_" is used instead of "-".
  _permalink = if !self.index('_').nil?
    self.to_url(replace_whitespace_with: '_')
  else
    self.to_url
  end

  underscore ? _permalink.underscore : _permalink
end

#permalink!(underscore = false) ⇒ Object Also known as: parameterize!


27
28
29
# File 'lib/locomotive/core_ext.rb', line 27

def permalink!(underscore = false)
  replace(self.permalink(underscore))
end