class Middleman::CoreExtensions::DefaultHelpers

def page_classes(path=current_path.dup, options={})

Returns:
  • (String) -
def page_classes(path=current_path.dup, options={})
  if path.is_a? Hash
    options = path
    path = current_path.dup
  end
  path << index_file if path.end_with?('/')
  path = ::Middleman::Util.strip_leading_slash(path)
  classes = Set.new
  parts = path.split('.').first.split('/')
  parts.each_with_index { |_, i| classes << parts.first(i + 1).join('_') }
  prefix = options[:numeric_prefix] || 'x'
  classes.map do |c|
    # Replace weird class name characters
    c = c.gsub(/[^a-zA-Z0-9\-_]/, '-')
    # Class names can't start with a digit
    c = "#{prefix}#{c}" if c =~ /\A\d/
    c
  end.join(' ')
end