mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
Clean page classes of invalid CSS characters and make sure they don't start with a number
This commit is contained in:
parent
fd85ca90a3
commit
4055479ff3
1 changed files with 8 additions and 1 deletions
|
@ -141,7 +141,14 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
|
||||||
parts = path.split('.').first.split('/')
|
parts = path.split('.').first.split('/')
|
||||||
parts.each_with_index { |path, i| classes << parts.first(i+1).join('_') }
|
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
|
end
|
||||||
|
|
||||||
# Get the path of a file of a given type
|
# Get the path of a file of a given type
|
||||||
|
|
Loading…
Reference in a new issue