diff --git a/lib/sass/engine.rb b/lib/sass/engine.rb index 8e979026..82772dfb 100644 --- a/lib/sass/engine.rb +++ b/lib/sass/engine.rb @@ -38,7 +38,7 @@ module Sass # def initialize(template, options={}) @options = { - :style => :compact + :style => :nested }.merge! options @template = template.split("\n") @lines = [] diff --git a/lib/sass/plugin.rb b/lib/sass/plugin.rb index 820d178a..2b3425dc 100644 --- a/lib/sass/plugin.rb +++ b/lib/sass/plugin.rb @@ -15,8 +15,7 @@ module Sass :template_location => RAILS_ROOT + '/public/stylesheets/sass', :css_location => RAILS_ROOT + '/public/stylesheets', :always_update => false, - :always_check => RAILS_ENV != "production", - :style => :nested + :always_check => RAILS_ENV != "production" } # Gets various options for Sass. See README for details. diff --git a/lib/sass/tree/attr_node.rb b/lib/sass/tree/attr_node.rb index d7120c91..90127047 100644 --- a/lib/sass/tree/attr_node.rb +++ b/lib/sass/tree/attr_node.rb @@ -18,12 +18,13 @@ module Sass::Tree if children.size > 0 to_return = String.new children.each do |kid| - if @style == :expanded - to_return << "#{kid.to_s(real_name)}\n " - else + if @style == :compact to_return << "#{kid.to_s(real_name)} " + else + to_return << "#{kid.to_s(real_name)}\n" end end + to_return << "\n" unless @style == :compact to_return[0...-1] else if value.length < 1 diff --git a/lib/sass/tree/node.rb b/lib/sass/tree/node.rb index e555f32f..4655a50f 100644 --- a/lib/sass/tree/node.rb +++ b/lib/sass/tree/node.rb @@ -20,7 +20,7 @@ module Sass raise SyntaxError.new('Attributes aren\'t allowed at the root of a document.', child.line) end - result += "#{child.to_s}\n" + result += "#{child.to_s(1)}\n" end result[0...-1] end diff --git a/lib/sass/tree/rule_node.rb b/lib/sass/tree/rule_node.rb index 3498d31c..ca26d314 100644 --- a/lib/sass/tree/rule_node.rb +++ b/lib/sass/tree/rule_node.rb @@ -6,11 +6,11 @@ module Sass::Tree alias_method :rule, :value alias_method :rule=, :value= - def to_s(super_rules = nil) + def to_s(tabs, super_rules = nil) attributes = [] sub_rules = [] total_rule = if super_rules - super_rules.split(/,\s*/).collect! do |s| + super_rules.split(/,\s*/).collect! do |s| self.rule.split(/,\s*/).collect! {|r| "#{s} #{r}"}.join(", ") end.join(", ") else @@ -27,14 +27,20 @@ module Sass::Tree to_return = '' unless attributes.empty? - if @style == :expanded - to_return << "#{total_rule} {\n #{attributes.join("\n ").rstrip}\n}\n" - else + if @style == :compact to_return << "#{total_rule} { #{attributes.join(' ')} }\n" + else + spaces = (@style == :expanded ? 2 : tabs * 2) + old_spaces = ' ' * (spaces - 2) + spaces = ' ' * spaces + + attributes = attributes.join("\n").gsub("\n", "\n#{spaces}").rstrip + end_attrs = (@style == :expanded ? "\n" : ' ') + to_return << "#{old_spaces}#{total_rule} {\n#{spaces}#{attributes}#{end_attrs}}\n" end end - sub_rules.each { |sub| to_return << sub.to_s(total_rule) } + sub_rules.each { |sub| to_return << sub.to_s(tabs + 1, total_rule) } to_return end end diff --git a/test/haml/results/filters.xhtml b/test/haml/results/filters.xhtml index 884449c8..a336a9c3 100644 --- a/test/haml/results/filters.xhtml +++ b/test/haml/results/filters.xhtml @@ -1,7 +1,11 @@ TESTING HAHAHAHA!