Class: String

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

Overview

String

Instance Method Summary collapse

Instance Method Details

:nodoc



7
8
9
10
11
12
13
14
15
16
# File 'lib/locomotive/core_ext.rb', line 7

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!



18
19
20
# File 'lib/locomotive/core_ext.rb', line 18

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