module Sassfmt
Constants
- PROPERTY_ORDER
From github.com/brigade/scss-lint/blob/fe04ca9de2d1cf1b28122fb3add7116bef995edd/data/property-sort-orders/recess.txt which itself was modified from github.com/twitter/recess.
- PROPERTY_REGEXP
- VERSION
Public Class Methods
format(sass)
click to toggle source
# File lib/sassfmt.rb, line 40 def self.format(sass) sass.lines.chunk do |line| [!!(line =~ PROPERTY_REGEXP), line.match(/^\s*/)[0].size] end.flat_map do |((is_property, _), lines)| if is_property lines.sort_by.with_index do |line, i| [PROPERTY_ORDER[line.match(PROPERTY_REGEXP)[1]] || Float::INFINITY, i] end else lines end end.join end