lib/nanoc/toolbox/helpers/blogging_extra.rb
def slug_for(item)
      return item[:slug] if item[:slug]

      item[:slug] = File.basename(item[:filename], File.extname(item[:filename]))
      item[:slug].gsub!(/\s+/, '-')
      item[:slug]
    end
# Get an item's slug if it has one, or use its filename sans extension
#
# @param [Nanoc::Item] item the item that will act as a post
# @return [String] either the slug specified in the item or generate one
#
# @example
#   # item[:filename] = "abc def geh.html"
#   slug_for(item) # => "abc-def-geh"
Get an item's slug if it has one, or use its filename sans extension
Get an item ' s slug if it has one or use its filename sans extension
def slug_for(item)
      return item[:slug] if item[:slug]
      item[:slug] = File.basename(item[:filename], File.extname(item[:filename]))
      item[:slug].gsub!(/\s+/, '-')
      item[:slug]
    end
def slug_for ( item ) return item [ :slug ] if item [ :slug ] item [ :slug ] = File . basename ( item [ :filename ] , File . extname ( item [ :filename ] ) ) item [ :slug ] . gsub! ( / \s + / , '-' ) item [ :slug ] end
Get an item's slug if it has one, or use its filename sans extension
Get an item ' s slug if it has one or use its filename sans extension
either the slug specified in the item or generate one
either the slug specified in the item or generate one
String
item
item the item that will act as a post
item the item that will act as a post
example
item[:filename] = "abc def geh.html" slug_for(item) # => "abc-def-geh"
item [ : filename ] = " abc def geh . html " slug_for ( item ) # = > " abc - def - geh "