Merge pull request #1049 from bhollis/classes

Clean page classes of invalid CSS characters
This commit is contained in:
Thomas Reynolds 2013-10-29 09:23:05 -07:00
commit 1e57eb5c1b

View file

@ -141,7 +141,14 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
parts = path.split('.').first.split('/')
parts.each_with_index { |path, i| classes << parts.first(i+1).join('_') }
classes.join(' ')
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 = "x#{c}" if c =~ /\A\d/
c
end.join(' ')
end
# Get the path of a file of a given type