| Class | Less::Node::Expression |
| In: |
lib/sass/less.rb
|
| Parent: | Object |
| LESS_TO_SASS_OPERATORS | = | {"-" => :minus, "+" => :plus, "*" => :times, "/" => :div, "=" => :single_eq} |
# File lib/sass/less.rb, line 235
235: def to_sass_tree
236: if first.is_a?(Array)
237: val = map {|e| _to_sass_tree(e)}.inject(nil) do |e, i|
238: next i unless e
239: Sass::Script::Operation.new(e, i, :comma)
240: end
241: else
242: val = _to_sass_tree(self)
243: end
244: val.options = {}
245: val
246: end
# File lib/sass/less.rb, line 271
271: def _sass_split(arr)
272: return arr[0].to_sass_tree, arr[1..-1] unless arr[0] == "("
273: parens = 1
274: i = arr[1..-1].each_with_index do |e, i|
275: parens += 1 if e == "("
276: parens -= 1 if e == ")"
277: break i if parens == 0
278: end
279:
280: return _to_sass_tree(arr[1...i+1]), arr[i+2..-1]
281: end
# File lib/sass/less.rb, line 251
251: def _to_sass_tree(arr)
252: return Sass::Script::UnaryOperation.new(_to_sass_tree(arr[1..-1]), :minus) if arr[0] == "-"
253: _to_sass_tree2(*_sass_split(arr))
254: end
# File lib/sass/less.rb, line 256
256: def _to_sass_tree2(first, rest)
257: return first if rest.empty?
258: if rest[0].is_a?(Operator)
259: op = LESS_TO_SASS_OPERATORS[rest[0]]
260: if op == :times || op == :div
261: second, rest = _sass_split(rest[1..-1])
262: return _to_sass_tree2(Sass::Script::Operation.new(first, second, op), rest)
263: else
264: return Sass::Script::Operation.new(first, _to_sass_tree(rest[1..-1]), op)
265: end
266: end
267:
268: Sass::Script::Operation.new(first, _to_sass_tree(rest), :concat)
269: end