haml-edge 2.3.213 → 2.3.214

Sign up to get free protection for your applications and to get access to all the features.
data/EDGE_GEM_VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.213
1
+ 2.3.214
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.213
1
+ 2.3.214
@@ -46,6 +46,11 @@ module Sass::Tree
46
46
 
47
47
  protected
48
48
 
49
+ # @see Node#to_src
50
+ def to_src(tabs, opts, fmt)
51
+ "#{' ' * tabs}@extend #{selector_to_src(@selector, tabs, opts, fmt).lstrip}#{semi fmt}\n"
52
+ end
53
+
49
54
  # Runs SassScript interpolation in the selector,
50
55
  # and then parses the result into a {Sass::Selector::CommaSequence}.
51
56
  #
@@ -400,13 +400,50 @@ module Sass
400
400
  # @param tabs [Fixnum] The amount of tabulation to use for the Sass code
401
401
  # @param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize})
402
402
  # @param fmt [Symbol] `:sass` or `:scss`
403
- # @return [String] The Sass or CSS code corresponding to the children
403
+ # @return [String] The Sass or SCSS code corresponding to the children
404
404
  def children_to_src(tabs, opts, fmt)
405
405
  (fmt == :sass ? "\n" : " {\n") +
406
406
  children.map {|c| c.send("to_#{fmt}", tabs + 1, opts)}.join.rstrip +
407
407
  (fmt == :sass ? "\n" : " }\n")
408
408
  end
409
409
 
410
+ # Converts a selector to a Sass or SCSS string.
411
+ #
412
+ # @param sel [Array<String, Sass::Script::Node>] The selector to convert
413
+ # @param tabs [Fixnum] The indentation of the selector
414
+ # @param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize})
415
+ # @param fmt [Symbol] `:sass` or `:scss`
416
+ # @return [String] The Sass or SCSS code corresponding to the selector
417
+ def selector_to_src(sel, tabs, opts, fmt)
418
+ fmt == :sass ? selector_to_sass(sel, opts) : selector_to_scss(sel, tabs, opts)
419
+ end
420
+
421
+ # Converts a selector to a Sass string.
422
+ #
423
+ # @param sel [Array<String, Sass::Script::Node>] The selector to convert
424
+ # @param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize})
425
+ # @return [String] The Sass code corresponding to the selector
426
+ def selector_to_sass(sel, opts)
427
+ sel.map do |r|
428
+ if r.is_a?(String)
429
+ r.gsub(/(,[ \t]*)?\n\s*/) {$1 ? $1 + "\n" : " "}
430
+ else
431
+ "\#{#{r.to_sass(opts)}}"
432
+ end
433
+ end.join
434
+ end
435
+
436
+ # Converts a selector to a SCSS string.
437
+ #
438
+ # @param sel [Array<String, Sass::Script::Node>] The selector to convert
439
+ # @param tabs [Fixnum] The indentation of the selector
440
+ # @param opts [{Symbol => Object}] An options hash (see {Sass::CSS#initialize})
441
+ # @return [String] The SCSS code corresponding to the selector
442
+ def selector_to_scss(sel, tabs, opts)
443
+ sel.map {|r| r.is_a?(String) ? r : "\#{#{r.to_sass(opts)}}"}.
444
+ join.gsub(/^[ \t]*/, ' ' * tabs)
445
+ end
446
+
410
447
  # Convert any underscores in a string into hyphens,
411
448
  # but only if the `:dasherize` option is set.
412
449
  #
@@ -84,22 +84,14 @@ module Sass::Tree
84
84
 
85
85
  # @see Node#to_sass
86
86
  def to_sass(tabs, opts = {})
87
- name = rule.map do |r|
88
- if r.is_a?(String)
89
- r.gsub(/(,[ \t]*)?\n\s*/) {$1 ? $1 + "\n" : " "}
90
- else
91
- "\#{#{r.to_sass(opts)}}"
92
- end
93
- end.join
87
+ name = selector_to_sass(rule, opts)
94
88
  name = "\\" + name if name[0] == ?:
95
89
  name.gsub(/^/, ' ' * tabs) + children_to_src(tabs, opts, :sass)
96
90
  end
97
91
 
98
92
  # @see Node#to_scss
99
93
  def to_scss(tabs, opts = {})
100
- name = rule.map {|r| r.is_a?(String) ? r : "\#{#{r.to_sass(opts)}}"}.
101
- join.gsub(/^[ \t]*/, ' ' * tabs)
102
-
94
+ name = selector_to_scss(rule, tabs, opts)
103
95
  res = name + children_to_src(tabs, opts, :scss)
104
96
 
105
97
  if children.last.is_a?(CommentNode) && children.last.silent
@@ -727,6 +727,18 @@ SASS
727
727
  SCSS
728
728
  end
729
729
 
730
+ def test_extend
731
+ assert_renders <<SASS, <<SCSS
732
+ .foo
733
+ @extend .bar
734
+ @extend .baz:bang
735
+ SASS
736
+ .foo {
737
+ @extend .bar;
738
+ @extend .baz:bang; }
739
+ SCSS
740
+ end
741
+
730
742
  def test_argless_mixin_definition
731
743
  assert_renders <<SASS, <<SCSS
732
744
  =foo-bar
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml-edge
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.213
4
+ version: 2.3.214
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Weizenbaum