GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Fork of nex3/haml
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/chriseppstein/haml.git
Expand commas in css2sass so that at least they'll render properly. Not a 
perfect solution.

git-svn-id: svn://hamptoncatlin.com/haml/trunk@701 
7063305b-7217-0410-af8c-cdc13e5119b9
nex3 (author)
Sun Dec 16 14:22:56 -0800 2007
commit  c882b2d33275b574615fded8516f9d02da34d710
tree    0fa3f185a77dfa6f0a758d4c84150bade3c659c8
parent  0f41f43e761e5e578625bab49a5ce1a6cdeaab9d
...
118
119
120
 
121
122
123
...
194
195
196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
198
199
...
214
215
216
217
218
 
219
220
221
...
118
119
120
121
122
123
124
...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
...
243
244
245
 
 
246
247
248
249
0
@@ -118,6 +118,7 @@ module Sass
0
       whitespace
0
       directives root
0
       rules root
0
+ expand_commas root
0
       nest_rules root
0
       flatten_rules root
0
       root
0
@@ -194,6 +195,34 @@ module Sass
0
       whitespace
0
     end
0
 
0
+ # Transform
0
+ #
0
+ # foo, bar, baz
0
+ # color: blue
0
+ #
0
+ # into
0
+ #
0
+ # foo
0
+ # color: blue
0
+ # bar
0
+ # color: blue
0
+ # baz
0
+ # color: blue
0
+ #
0
+ # Yes, this expands the amount of code,
0
+ # but it's necessary to get nesting to work properly.
0
+ def expand_commas(root)
0
+ root.children.map! do |child|
0
+ next child unless Tree::RuleNode === child && child.rule.include?(',')
0
+ child.rule.split(',').map do |rule|
0
+ node = Tree::RuleNode.new(rule, nil)
0
+ node.children = child.children
0
+ node
0
+ end
0
+ end
0
+ root.children.flatten!
0
+ end
0
+
0
     # Nest rules so that
0
     #
0
     # foo
0
@@ -214,8 +243,7 @@ module Sass
0
     #
0
     def nest_rules(root)
0
       rules = OrderedHash.new
0
- root.children.dup.each do |child|
0
- next unless child.is_a? Tree::RuleNode
0
+ root.children.select { |c| Tree::RuleNode === c }.each do |child|
0
         root.children.delete child
0
         first, rest = child.rule.split(' ', 2)
0
         rules[first] ||= Tree::RuleNode.new(first, nil)

Comments

    No one has commented yet.