haml-edge 2.3.186 → 2.3.187

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. data/EDGE_GEM_VERSION +1 -1
  2. data/VERSION +1 -1
  3. data/lib/haml/exec.rb +94 -18
  4. data/lib/haml/helpers.rb +3 -1
  5. data/lib/sass/engine.rb +1 -1
  6. data/lib/sass/script/bool.rb +1 -1
  7. data/lib/sass/script/color.rb +1 -1
  8. data/lib/sass/script/funcall.rb +2 -2
  9. data/lib/sass/script/interpolation.rb +5 -5
  10. data/lib/sass/script/literal.rb +1 -1
  11. data/lib/sass/script/node.rb +10 -1
  12. data/lib/sass/script/number.rb +1 -1
  13. data/lib/sass/script/operation.rb +5 -5
  14. data/lib/sass/script/string.rb +12 -5
  15. data/lib/sass/script/unary_operation.rb +3 -3
  16. data/lib/sass/script/variable.rb +2 -2
  17. data/lib/sass/scss/css_parser.rb +1 -0
  18. data/lib/sass/scss/parser.rb +45 -25
  19. data/lib/sass/scss/rx.rb +1 -0
  20. data/lib/sass/tree/for_node.rb +1 -1
  21. data/lib/sass/tree/if_node.rb +1 -1
  22. data/lib/sass/tree/mixin_def_node.rb +3 -3
  23. data/lib/sass/tree/mixin_node.rb +2 -2
  24. data/lib/sass/tree/node.rb +8 -0
  25. data/lib/sass/tree/prop_node.rb +17 -16
  26. data/lib/sass/tree/rule_node.rb +2 -2
  27. data/lib/sass/tree/variable_node.rb +1 -1
  28. data/lib/sass/tree/while_node.rb +1 -1
  29. data/test/sass/conversion_test.rb +47 -0
  30. data/test/sass/scss/css_test.rb +3 -3
  31. data/test/sass/scss/scss_test.rb +40 -0
  32. metadata +2 -37
  33. data/test/haml/spec/README.md +0 -97
  34. data/test/haml/spec/lua_haml_spec.lua +0 -30
  35. data/test/haml/spec/ruby_haml_test.rb +0 -19
  36. data/test/haml/spec/tests.json +0 -534
  37. data/vendor/fssm/LICENSE +0 -20
  38. data/vendor/fssm/README.markdown +0 -55
  39. data/vendor/fssm/Rakefile +0 -59
  40. data/vendor/fssm/VERSION.yml +0 -5
  41. data/vendor/fssm/example.rb +0 -9
  42. data/vendor/fssm/fssm.gemspec +0 -77
  43. data/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
  44. data/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
  45. data/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
  46. data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
  47. data/vendor/fssm/lib/fssm/monitor.rb +0 -26
  48. data/vendor/fssm/lib/fssm/path.rb +0 -91
  49. data/vendor/fssm/lib/fssm/pathname.rb +0 -502
  50. data/vendor/fssm/lib/fssm/state/directory.rb +0 -57
  51. data/vendor/fssm/lib/fssm/state/file.rb +0 -24
  52. data/vendor/fssm/lib/fssm/support.rb +0 -63
  53. data/vendor/fssm/lib/fssm/tree.rb +0 -176
  54. data/vendor/fssm/lib/fssm.rb +0 -33
  55. data/vendor/fssm/profile/prof-cache.rb +0 -40
  56. data/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
  57. data/vendor/fssm/profile/prof-pathname.rb +0 -68
  58. data/vendor/fssm/profile/prof-plain-pathname.html +0 -988
  59. data/vendor/fssm/profile/prof.html +0 -2379
  60. data/vendor/fssm/spec/path_spec.rb +0 -75
  61. data/vendor/fssm/spec/root/duck/quack.txt +0 -0
  62. data/vendor/fssm/spec/root/file.css +0 -0
  63. data/vendor/fssm/spec/root/file.rb +0 -0
  64. data/vendor/fssm/spec/root/file.yml +0 -0
  65. data/vendor/fssm/spec/root/moo/cow.txt +0 -0
  66. data/vendor/fssm/spec/spec_helper.rb +0 -14
data/EDGE_GEM_VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.186
1
+ 2.3.187
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.186
1
+ 2.3.187
data/lib/haml/exec.rb CHANGED
@@ -105,6 +105,39 @@ module Haml
105
105
  @options[:input], @options[:output] = input, output
106
106
  end
107
107
 
108
+ # @private
109
+ COLORS = { :red => 31, :green => 32, :yellow => 33 }
110
+
111
+ # Prints a status message about performing the given action,
112
+ # colored using the given color (via terminal escapes) if possible.
113
+ #
114
+ # @param name [#to_s] A short name for the action being performed.
115
+ # Shouldn't be longer than 11 characters.
116
+ # @param color [Symbol] The name of the color to use for this action.
117
+ # Can be `:red`, `:green`, or `:yellow`.
118
+ def puts_action(name, color, arg)
119
+ printf color(color, "%11s %s\n"), name, arg
120
+ end
121
+
122
+ # Wraps the given string in terminal escapes
123
+ # causing it to have the given color.
124
+ # If terminal esapes aren't supported on this platform,
125
+ # just returns the string instead.
126
+ #
127
+ # @param color [Symbol] The name of the color to use.
128
+ # Can be `:red`, `:green`, or `:yellow`.
129
+ # @param str [String] The string to wrap in the given color.
130
+ # @return [String] The wrapped string.
131
+ def color(color, str)
132
+ raise "[BUG] Unrecognized color #{color}" unless COLORS[color]
133
+
134
+ # Almost any real Unix terminal will support color,
135
+ # so we just filter for Windows terms (which don't set TERM)
136
+ # and not-real terminals, which aren't ttys.
137
+ return str if ENV["TERM"].nil? || ENV["TERM"].empty? || !STDOUT.tty?
138
+ return "\e[#{COLORS[color]}m#{str}\e[0m"
139
+ end
140
+
108
141
  private
109
142
 
110
143
  def open_file(filename, flag = 'r')
@@ -358,23 +391,6 @@ MSG
358
391
 
359
392
  ::Sass::Plugin.watch(files)
360
393
  end
361
-
362
- # @private
363
- COLORS = { :red => 31, :green => 32, :yellow => 33 }
364
-
365
- def puts_action(name, color, arg)
366
- printf color(color, "%11s %s\n"), name, arg
367
- end
368
-
369
- def color(color, str)
370
- raise "[BUG] Unrecognized color #{color}" unless COLORS[color]
371
-
372
- # Almost any real Unix terminal will support color,
373
- # so we just filter for Windows terms (which don't set TERM)
374
- # and not-real terminals, which aren't ttys.
375
- return str if ENV["TERM"].nil? || ENV["TERM"].empty? || !STDOUT.tty?
376
- return "\e[#{COLORS[color]}m#{str}\e[0m"
377
- end
378
394
  end
379
395
 
380
396
  # The `haml` executable.
@@ -574,12 +590,21 @@ END
574
590
  @options[:to] = name.downcase.to_sym
575
591
  end
576
592
 
593
+ opts.on('-R', '--recursive',
594
+ 'Convert all the files in a directory. Requires --from and --to.') do
595
+ @options[:recursive] = true
596
+ end
597
+
577
598
  opts.on('-i', '--in-place',
578
599
  'Convert a file to its own syntax.',
579
600
  'This can be used to update some deprecated syntax.') do
580
601
  @options[:in_place] = true
581
602
  end
582
603
 
604
+ opts.on('--dasherize', 'Convert underscores to dashes') do
605
+ @options[:dasherize] = true
606
+ end
607
+
583
608
  opts.on('--old', 'Output the old-style ":prop val" property syntax.',
584
609
  'Only meaningful when generating Sass.') do
585
610
  @options[:for_tree][:old] = true
@@ -596,12 +621,63 @@ END
596
621
  # and runs the CSS compiler appropriately.
597
622
  def process_result
598
623
  require 'sass'
599
- super
600
624
 
625
+ if @options[:recursive]
626
+ process_directory
627
+ return
628
+ end
629
+
630
+ super
601
631
  input = @options[:input]
632
+ raise "Error: '#{input}' is a directory (did you mean to use --recursive?)" if File.directory?(input)
602
633
  output = @options[:output]
603
634
  output = input if @options[:in_place]
635
+ process_file(input, output)
636
+ end
637
+
638
+ def process_directory
639
+ input = @options[:input] = @args.shift
640
+ output = @options[:output] = @args.shift
641
+ raise "Error: --from required when using --recursive." unless @options[:from]
642
+ raise "Error: --to required when using --recursive." unless @options[:to]
643
+ raise "Error: '#{@options[:input]}' is not a directory" unless File.directory?(@options[:input])
644
+ if @options[:output] && File.exists?(@options[:output]) && !File.directory?(@options[:output])
645
+ raise "Error: '#{@options[:output]}' is not a directory"
646
+ end
647
+ @options[:output] ||= @options[:input]
648
+
649
+ ext = @options[:from]
650
+ ext = :sass if ext == :sass2
651
+ Dir.glob("#{@options[:input]}/**/*.#{ext}") do |f|
652
+ output =
653
+ if @options[:in_place]
654
+ f
655
+ elsif @options[:output]
656
+ output_name = f.gsub(/\.(c|sa|sc)ss$/, ".#{@options[:to]}")
657
+ output_name[0...@options[:input].size] = @options[:output]
658
+ output_name
659
+ else
660
+ f.gsub(/\.(c|sa|sc)ss$/, ".#{@options[:to]}")
661
+ end
662
+
663
+ unless File.directory?(File.dirname(output))
664
+ puts_action :directory, :green, File.dirname(output)
665
+ FileUtils.mkdir_p(File.dirname(output))
666
+ end
667
+ puts_action :convert, :green, f
668
+ if File.exists?(output)
669
+ puts_action :overwrite, :yellow, output
670
+ else
671
+ puts_action :create, :green, output
672
+ end
673
+
674
+ input = open_file(f)
675
+ output = @options[:in_place] ? input : open_file(output, "w")
676
+ process_file(input, output)
677
+ end
678
+ end
604
679
 
680
+ def process_file(input, output)
605
681
  if input.is_a?(File)
606
682
  @options[:from] ||=
607
683
  case input.path
data/lib/haml/helpers.rb CHANGED
@@ -348,7 +348,9 @@ MESSAGE
348
348
  haml_buffer.capture_position = position
349
349
  block.call(*args)
350
350
 
351
- captured = haml_buffer.buffer.slice!(position..-1).split(/^/)
351
+ captured = haml_buffer.buffer.slice!(position..-1)
352
+ return captured if haml_buffer.options[:ugly]
353
+ captured = captured.split(/^/)
352
354
 
353
355
  min_tabs = nil
354
356
  captured.each do |line|
data/lib/sass/engine.rb CHANGED
@@ -415,7 +415,7 @@ WARNING
415
415
  if eq.strip[0] == SCRIPT_CHAR
416
416
  expr.context = :equals
417
417
  Script.equals_warning("properties", name,
418
- Sass::Tree::PropNode.val_to_sass(expr), false,
418
+ Sass::Tree::PropNode.val_to_sass(expr, @options), false,
419
419
  @line, line.offset + 1, @options[:filename])
420
420
  end
421
421
  end
@@ -10,7 +10,7 @@ module Sass::Script
10
10
  alias_method :to_bool, :value
11
11
 
12
12
  # @return [String] "true" or "false"
13
- def to_s
13
+ def to_s(opts = {})
14
14
  @value.to_s
15
15
  end
16
16
  alias_method :to_sass, :to_s
@@ -375,7 +375,7 @@ END
375
375
  # but if the color has a name that's used instead.
376
376
  #
377
377
  # @return [String] The string representation
378
- def to_s
378
+ def to_s(opts = {})
379
379
  return rgba_str if alpha?
380
380
  return smallest if options[:style] == :compressed
381
381
  return HTML4_COLORS_REVERSE[rgb] if HTML4_COLORS_REVERSE[rgb]
@@ -31,8 +31,8 @@ module Sass
31
31
  end
32
32
 
33
33
  # @see Node#to_sass
34
- def to_sass
35
- "#{name}(#{args.map {|a| a.to_sass}.join(', ')})"
34
+ def to_sass(opts = {})
35
+ "#{dasherize(name, opts)}(#{args.map {|a| a.to_sass(opts)}.join(', ')})"
36
36
  end
37
37
 
38
38
  # Returns the arguments to the function.
@@ -9,16 +9,16 @@ module Sass::Script
9
9
  end
10
10
 
11
11
  def inspect
12
- "(interpolation #{@before.inspect} #{@mid.inspect} #{after.inspect})"
12
+ "(interpolation #{@before.inspect} #{@mid.inspect} #{@after.inspect})"
13
13
  end
14
14
 
15
- def to_sass
15
+ def to_sass(opts = {})
16
16
  res = ""
17
- res << @before.to_sass if @before
17
+ res << @before.to_sass(opts) if @before
18
18
  res << ' ' if @before && @whitespace_before
19
- res << '#{' << @mid.to_sass << '}'
19
+ res << '#{' << @mid.to_sass(opts) << '}'
20
20
  res << ' ' if @after && @whitespace_after
21
- res << @after.to_sass if @after
21
+ res << @after.to_sass(opts) if @after
22
22
  res
23
23
  end
24
24
 
@@ -218,7 +218,7 @@ MSG
218
218
  # as it would be output to the CSS document.
219
219
  #
220
220
  # @return [String]
221
- def to_s
221
+ def to_s(opts = {})
222
222
  raise Sass::SyntaxError.new("[BUG] All subclasses of Sass::Literal must implement #to_s.")
223
223
  end
224
224
  alias_method :to_sass, :to_s
@@ -74,12 +74,21 @@ module Sass::Script
74
74
  # Returns the text of this SassScript expression.
75
75
  #
76
76
  # @return [String]
77
- def to_sass
77
+ def to_sass(opts = {})
78
78
  raise NotImplementedError.new("All subclasses of Sass::Script::Node must override #to_sass.")
79
79
  end
80
80
 
81
81
  protected
82
82
 
83
+ # Converts underscores to dashes if the :dasherize option is set.
84
+ def dasherize(s, opts)
85
+ if opts[:dasherize]
86
+ s.gsub(/_/,'-')
87
+ else
88
+ s
89
+ end
90
+ end
91
+
83
92
  # Evaluates this node.
84
93
  #
85
94
  # @param environment [Sass::Environment] The environment in which to evaluate the SassScript
@@ -238,7 +238,7 @@ module Sass::Script
238
238
  # as long as there is only one unit.
239
239
  #
240
240
  # @return [String] The representation
241
- def inspect
241
+ def inspect(opts = {})
242
242
  value =
243
243
  if self.value.is_a?(Float) && (self.value.infinite? || self.value.nan?)
244
244
  self.value
@@ -33,10 +33,10 @@ module Sass::Script
33
33
  end
34
34
 
35
35
  # @see Node#to_sass
36
- def to_sass
36
+ def to_sass(opts = {})
37
37
  pred = Sass::Script::Parser.precedence_of(@operator)
38
- o1 = operand_to_sass pred, @operand1
39
- o2 = operand_to_sass pred, @operand2
38
+ o1 = operand_to_sass pred, @operand1, opts
39
+ o2 = operand_to_sass pred, @operand2, opts
40
40
  sep =
41
41
  case @operator
42
42
  when :comma; ", "
@@ -82,10 +82,10 @@ module Sass::Script
82
82
 
83
83
  private
84
84
 
85
- def operand_to_sass(pred, op)
85
+ def operand_to_sass(pred, op, opts = {})
86
86
  return "(#{op.to_sass})" if op.is_a?(Operation) &&
87
87
  Sass::Script::Parser.precedence_of(op.operator) < pred
88
- op.to_sass
88
+ op.to_sass(opts)
89
89
  end
90
90
  end
91
91
  end
@@ -35,23 +35,30 @@ module Sass::Script
35
35
  end
36
36
 
37
37
  # @see Node#to_s
38
- def to_s
39
- to_sass
38
+ def to_s(opts = {})
39
+ to_sass(opts)
40
40
  end
41
41
 
42
- # @param type [Symbol] The type of string to render this as.
43
- # `:string`s have double quotes, `:identifier`s do not.
42
+ # @param opts [{Symbol => Object}]
43
+ # `opts[:type]` -- The type of string to render this as.
44
+ # `:string`s have double quotes, `:identifier`s do not.
45
+ # Defaults to `:identifier`.
44
46
  # @see Node#to_sass
45
- def to_sass(type = self.type)
47
+ def to_sass(opts = {})
48
+ type = opts[:type] || self.type
46
49
  if type == :identifier
47
50
  if context == :equals && Sass::SCSS::RX.escape_ident(self.value).include?(?\\)
48
51
  return "unquote(#{Sass::Script::String.new(self.value, :string).to_sass})"
52
+ elsif context == :equals && self.value.size == 0
53
+ return %q{""}
49
54
  end
50
55
  return self.value
51
56
  end
52
57
 
53
58
  # Replace single backslashes with double. Really.
54
59
  value = self.value.gsub("\\", "\\\\\\\\")
60
+ return "\"#{value.gsub('"', "\\\"")}\"" if opts[:quote] == %q{"}
61
+ return "'#{value.gsub("'", "\\'")}'" if opts[:quote] == %q{'}
55
62
  return "\"#{value}\"" unless value.include?('"')
56
63
  return "'#{value}'" unless value.include?("'")
57
64
  "\"#{value.gsub('"', "\\\"")}\"" #'
@@ -19,12 +19,12 @@ module Sass::Script
19
19
  end
20
20
 
21
21
  # @see Node#to_sass
22
- def to_sass
23
- operand = @operand.to_sass
22
+ def to_sass(opts = {})
23
+ operand = @operand.to_sass(opts)
24
24
  if @operand.is_a?(Operation) ||
25
25
  (@operator == :minus &&
26
26
  (operand =~ Sass::SCSS::RX::IDENT) == 0)
27
- operand = "(#{@operand.to_sass})"
27
+ operand = "(#{@operand.to_sass(opts)})"
28
28
  end
29
29
  op = Lexer::OPERATORS_REVERSE[@operator]
30
30
  op + (op =~ /[a-z]/ ? " " : "") + operand
@@ -14,9 +14,9 @@ module Sass
14
14
  end
15
15
 
16
16
  # @return [String] A string representation of the variable
17
- def inspect
17
+ def inspect(opts = {})
18
18
  return "!important" if name == "important"
19
- "$#{name}"
19
+ "$#{dasherize(name, opts)}"
20
20
  end
21
21
  alias_method :to_sass, :inspect
22
22
 
@@ -9,6 +9,7 @@ module Sass
9
9
  def parent_selector; nil; end
10
10
  def interpolation; nil; end
11
11
  def interp_string; tok(STRING); end
12
+ def interp_ident(ident = IDENT); tok(ident); end
12
13
  def expected_property_separator; '":"'; end
13
14
  def use_css_import?; true; end
14
15
 
@@ -366,12 +366,12 @@ module Sass
366
366
 
367
367
  def simple_selector_sequence
368
368
  # This allows for stuff like http://www.w3.org/TR/css3-animations/#keyframes-
369
- return expr unless e = element_name || tok(HASH) || class_expr ||
369
+ return expr unless e = element_name || id_selector || class_selector ||
370
370
  attrib || negation || pseudo || parent_selector || interpolation
371
371
  res = [e]
372
372
 
373
373
  # The tok(/\*/) allows the "E*" hack
374
- while v = element_name || tok(HASH) || class_expr ||
374
+ while v = element_name || id_selector || class_selector ||
375
375
  attrib || negation || pseudo || tok(/\*/) || interpolation
376
376
  res << v
377
377
  end
@@ -382,9 +382,16 @@ module Sass
382
382
  tok(/&/)
383
383
  end
384
384
 
385
- def class_expr
385
+ def class_selector
386
386
  return unless tok(/\./)
387
- '.' + tok!(IDENT)
387
+ @expected = "class name"
388
+ ['.', expr!(:interp_ident)]
389
+ end
390
+
391
+ def id_selector
392
+ return unless tok(/#(?!\{)/)
393
+ @expected = "id name"
394
+ ['#', expr!(:interp_name)]
388
395
  end
389
396
 
390
397
  def element_name
@@ -398,7 +405,7 @@ module Sass
398
405
 
399
406
  def attrib
400
407
  return unless tok(/\[/)
401
- res = ['[', str{ss}, str{attrib_name!}, str{ss}]
408
+ res = ['[', str{ss}, attrib_name!, str{ss}]
402
409
 
403
410
  if m = tok(/=/) ||
404
411
  tok(INCLUDES) ||
@@ -413,31 +420,29 @@ module Sass
413
420
  end
414
421
 
415
422
  def attrib_name!
416
- if tok(IDENT)
417
- # E, E|E, or E|
418
- # The last is allowed so that E|="foo" will work
419
- tok(IDENT) if tok(/\|/)
420
- elsif tok(/\*/)
421
- # *|E
422
- tok!(/\|/)
423
- tok! IDENT
423
+ if name_or_ns = interp_ident
424
+ # E, E|E
425
+ if tok(/\|(?!=)/)
426
+ ns = name_or_ns
427
+ name = interp_ident
428
+ else
429
+ name = name_or_ns
430
+ end
424
431
  else
425
- # |E or E
426
- tok(/\|/)
427
- tok! IDENT
432
+ # *|E or |E
433
+ ns = tok(/\*/) || ""
434
+ tok!(/\|/)
435
+ name = expr!(:interp_ident)
428
436
  end
437
+ return [ns, ("|" if ns), name]
429
438
  end
430
439
 
431
440
  def pseudo
432
441
  return unless s = tok(/::?/)
433
-
434
442
  @expected = "pseudoclass or pseudoelement"
435
- [s, functional_pseudo || tok!(IDENT)]
436
- end
437
-
438
- def functional_pseudo
439
- return unless fn = tok(FUNCTION)
440
- [fn, str{ss}, expr!(:pseudo_expr), tok!(/\)/)]
443
+ res = [s, expr!(:interp_ident)]
444
+ return res unless tok(/\(/)
445
+ res << '(' << str{ss} << expr!(:pseudo_expr) << tok!(/\)/)
441
446
  end
442
447
 
443
448
  def pseudo_expr
@@ -455,7 +460,7 @@ module Sass
455
460
  return unless tok(NOT)
456
461
  res = [":not(", str{ss}]
457
462
  @expected = "selector"
458
- res << (element_name || tok(HASH) || class_expr || attrib || expr!(:pseudo))
463
+ res << (element_name || id_selector || class_selector || attrib || expr!(:pseudo))
459
464
  res << tok!(/\)/)
460
465
  end
461
466
 
@@ -553,7 +558,7 @@ MESSAGE
553
558
  end
554
559
 
555
560
  def interpolation
556
- return unless tok(/#\{/)
561
+ return unless tok(INTERP_START)
557
562
  sass_script(:parse_interpolated)
558
563
  end
559
564
 
@@ -571,6 +576,19 @@ MESSAGE
571
576
  res
572
577
  end
573
578
 
579
+ def interp_ident(ident = IDENT)
580
+ return unless val = tok(ident) || interpolation
581
+ res = [val]
582
+ while val = tok(ident) || interpolation
583
+ res << val
584
+ end
585
+ res
586
+ end
587
+
588
+ def interp_name
589
+ interp_ident NAME
590
+ end
591
+
574
592
  def str
575
593
  @strs.push ""
576
594
  yield
@@ -608,6 +626,8 @@ MESSAGE
608
626
  :media_query => "media query (e.g. print, screen, print and screen)",
609
627
  :media_expr => "media expression (e.g. (min-device-width: 800px)))",
610
628
  :pseudo_expr => "expression (e.g. fr, 2n+1)",
629
+ :interp_ident => "identifier",
630
+ :interp_name => "identifier",
611
631
  :expr => "expression (e.g. 1px, bold)",
612
632
  }
613
633
 
data/lib/sass/scss/rx.rb CHANGED
@@ -107,6 +107,7 @@ module Sass
107
107
 
108
108
  # Custom
109
109
  HEXCOLOR = /\#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?/
110
+ INTERP_START = /#\{/
110
111
  end
111
112
  end
112
113
  end
@@ -22,7 +22,7 @@ module Sass::Tree
22
22
 
23
23
  def to_src(tabs, opts, fmt)
24
24
  to = @exclusive ? "to" : "through"
25
- "#{' ' * tabs}@for $#{@var} from #{@from.to_sass} #{to} #{@to.to_sass}" +
25
+ "#{' ' * tabs}@for $#{dasherize(@var, opts)} from #{@from.to_sass(opts)} #{to} #{@to.to_sass(opts)}" +
26
26
  children_to_src(tabs, opts, fmt)
27
27
  end
28
28
 
@@ -44,7 +44,7 @@ module Sass::Tree
44
44
  else; "else"
45
45
  end
46
46
  str = "#{' ' * tabs}@#{name}"
47
- str << " #{@expr.to_sass}" if @expr
47
+ str << " #{@expr.to_sass(opts)}" if @expr
48
48
  str << children_to_src(tabs, opts, fmt)
49
49
  str << @else.send(:to_src, tabs, opts, fmt, true) if @else
50
50
  str
@@ -23,14 +23,14 @@ module Sass
23
23
  else
24
24
  '(' + @args.map do |v, d|
25
25
  if d
26
- "#{v.to_sass}: #{d.to_sass}"
26
+ "#{v.to_sass(opts)}: #{d.to_sass(opts)}"
27
27
  else
28
- v.to_sass
28
+ v.to_sass(opts)
29
29
  end
30
30
  end.join(", ") + ')'
31
31
  end
32
32
 
33
- "#{' ' * tabs}#{fmt == :sass ? '=' : '@mixin '}#{@name}#{args}" +
33
+ "#{' ' * tabs}#{fmt == :sass ? '=' : '@mixin '}#{dasherize(@name, opts)}#{args}" +
34
34
  children_to_src(tabs, opts, fmt)
35
35
  end
36
36
 
@@ -29,8 +29,8 @@ module Sass::Tree
29
29
  protected
30
30
 
31
31
  def to_src(tabs, opts, fmt)
32
- args = '(' + @args.map {|a| a.to_sass}.join(", ") + ')' unless @args.empty?
33
- "#{' ' * tabs}#{fmt == :sass ? '+' : '@include '}#{@name}#{args}#{semi fmt}\n"
32
+ args = '(' + @args.map {|a| a.to_sass(opts)}.join(", ") + ')' unless @args.empty?
33
+ "#{' ' * tabs}#{fmt == :sass ? '+' : '@include '}#{dasherize(@name, opts)}#{args}#{semi fmt}\n"
34
34
  end
35
35
 
36
36
  # @see Node#_cssize
@@ -366,6 +366,14 @@ module Sass
366
366
  (fmt == :sass ? "\n" : " }\n")
367
367
  end
368
368
 
369
+ def dasherize(s, opts)
370
+ if opts[:dasherize]
371
+ s.gsub(/_/,'-')
372
+ else
373
+ s
374
+ end
375
+ end
376
+
369
377
  # Returns a semicolon if this is SCSS, or an empty string if this is Sass.
370
378
  #
371
379
  # @param fmt [Symbol] `:sass` or `:scss`
@@ -79,13 +79,13 @@ module Sass::Tree
79
79
  protected
80
80
 
81
81
  def to_src(tabs, opts, fmt)
82
- name = self.name.map {|n| n.is_a?(String) ? n : "\#{#{n.to_sass}}"}.join
82
+ name = self.name.map {|n| n.is_a?(String) ? n : "\#{#{n.to_sass(opts)}}"}.join
83
83
  old = opts[:old] && fmt == :sass
84
84
  initial = old ? ':' : ''
85
85
  mid = old ? '' : ':'
86
- res = "#{' ' * tabs}#{initial}#{name}#{mid} #{self.class.val_to_sass(value)}"
86
+ res = "#{' ' * tabs}#{initial}#{name}#{mid} #{self.class.val_to_sass(value, opts)}"
87
87
  return res + "#{semi fmt}\n" if children.empty?
88
- res.rstrip + children_to_src(tabs, opts, fmt)
88
+ res.rstrip + children_to_src(tabs, opts, fmt).rstrip + semi(fmt) + "\n"
89
89
  end
90
90
 
91
91
  # Computes the CSS for the property.
@@ -175,42 +175,43 @@ module Sass::Tree
175
175
 
176
176
  class << self
177
177
  # @private
178
- def val_to_sass(value)
179
- return value.to_sass unless value.context == :equals
180
- val_to_sass_comma(value).to_sass
178
+ def val_to_sass(value, opts)
179
+ return value.to_sass(opts) unless value.context == :equals
180
+ val_to_sass_comma(value, opts).to_sass(opts)
181
181
  end
182
182
 
183
183
  private
184
184
 
185
- def val_to_sass_comma(node)
185
+ def val_to_sass_comma(node, opts)
186
186
  return node unless node.is_a?(Sass::Script::Operation)
187
- return val_to_sass_concat(node) unless node.operator == :comma
187
+ return val_to_sass_concat(node, opts) unless node.operator == :comma
188
188
 
189
189
  Sass::Script::Operation.new(
190
- val_to_sass_concat(node.operand1),
191
- val_to_sass_comma(node.operand2),
190
+ val_to_sass_concat(node.operand1, opts),
191
+ val_to_sass_comma(node.operand2, opts),
192
192
  node.operator)
193
193
  end
194
194
 
195
- def val_to_sass_concat(node)
195
+ def val_to_sass_concat(node, opts)
196
196
  return node unless node.is_a?(Sass::Script::Operation)
197
- return val_to_sass_div(node) unless node.operator == :concat
197
+ return val_to_sass_div(node, opts) unless node.operator == :concat
198
198
 
199
199
  Sass::Script::Operation.new(
200
- val_to_sass_div(node.operand1),
201
- val_to_sass_concat(node.operand2),
200
+ val_to_sass_div(node.operand1, opts),
201
+ val_to_sass_concat(node.operand2, opts),
202
202
  node.operator)
203
203
  end
204
204
 
205
- def val_to_sass_div(node)
205
+ def val_to_sass_div(node, opts)
206
206
  unless node.is_a?(Sass::Script::Operation) && node.operator == :div &&
207
207
  node.operand1.is_a?(Sass::Script::Number) &&
208
208
  node.operand2.is_a?(Sass::Script::Number)
209
209
  return node
210
210
  end
211
211
 
212
- Sass::Script::String.new("(#{node.to_sass})")
212
+ Sass::Script::String.new("(#{node.to_sass(opts)})")
213
213
  end
214
+
214
215
  end
215
216
  end
216
217
  end