Module: TimelineSetter::Util
- Included in:
- Timeline
- Defined in:
- lib/timeline_setter/util.rb
Instance Method Summary (collapse)
-
- (Object) minify_css(css)
Utility method to lightly minify CSS — just remove \s+ where we can.
- - (Object) minify_html(html)
Instance Method Details
- (Object) minify_css(css)
Utility method to lightly minify CSS — just remove \s+ where we can.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/timeline_setter/util.rb', line 5 def minify_css(css) # take out new lines css.gsub!(/\n/,'') # take out spaces between selectors and rule blocks css.gsub!(/([\.a-zA-Z_\-\#]+?)\s*\{\s*([^\{\}\s])?/,'\1{\2') # take out spaces between rule block endings and selectors css.gsub!(/\}\s*([\.a-zA-Z_\-\#]+?)/,'}\1') # take out spaces between rules css.gsub!(/(:|;)(\s+)?([\.a-zA-Z_0-9]+)?/,'\1\3') # take out comments css.gsub!(/(\/\*.*?\*\/)/,' ') css end |
- (Object) minify_html(html)
24 25 26 |
# File 'lib/timeline_setter/util.rb', line 24 def minify_html(html) html.gsub(/(?:^|\s+?)(<.*?>)/, '\1') end |