mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Merge branch 'master' of git://github.com/nex3/haml
This commit is contained in:
commit
562a89e200
1 changed files with 19 additions and 2 deletions
|
@ -6,7 +6,7 @@ module Sass
|
|||
# :stopdoc:
|
||||
module Tree
|
||||
class Node
|
||||
def to_sass opts = {}
|
||||
def to_sass(opts = {})
|
||||
result = ''
|
||||
|
||||
children.each do |child|
|
||||
|
@ -313,6 +313,17 @@ module Sass
|
|||
# foo bar baz
|
||||
# color: red
|
||||
#
|
||||
# and
|
||||
#
|
||||
# foo
|
||||
# &.bar
|
||||
# color: blue
|
||||
#
|
||||
# becomes
|
||||
#
|
||||
# foo.bar
|
||||
# color: blue
|
||||
#
|
||||
def flatten_rules(root)
|
||||
root.children.each { |child| flatten_rule(child) if child.is_a?(Tree::RuleNode) }
|
||||
end
|
||||
|
@ -320,7 +331,13 @@ module Sass
|
|||
def flatten_rule(rule)
|
||||
while rule.children.size == 1 && rule.children.first.is_a?(Tree::RuleNode)
|
||||
child = rule.children.first
|
||||
rule.rule = "#{rule.rule} #{child.rule}"
|
||||
|
||||
if child.rule[0] == ?&
|
||||
rule.rule = child.rule.gsub /^&/, rule.rule
|
||||
else
|
||||
rule.rule = "#{rule.rule} #{child.rule}"
|
||||
end
|
||||
|
||||
rule.children = child.children
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue