haml 3.0.25 → 3.1.0.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of haml might be problematic. Click here for more details.
- data/.yardopts +1 -1
- data/CONTRIBUTING +0 -1
- data/EDGE_GEM_VERSION +1 -0
- data/MIT-LICENSE +1 -1
- data/README.md +10 -175
- data/Rakefile +56 -84
- data/VERSION +1 -1
- data/VERSION_NAME +1 -1
- data/init.rb +1 -1
- data/lib/haml.rb +14 -12
- data/lib/haml/engine.rb +1 -1
- data/lib/haml/exec.rb +19 -316
- data/lib/haml/helpers/action_view_extensions.rb +1 -1
- data/lib/haml/html.rb +69 -76
- data/lib/haml/precompiler.rb +34 -41
- data/lib/haml/railtie.rb +4 -6
- data/lib/haml/template/plugin.rb +6 -16
- data/lib/haml/util.rb +91 -107
- data/lib/haml/version.rb +7 -0
- data/test/benchmark.rb +2 -9
- data/test/haml/engine_test.rb +195 -92
- data/test/haml/html2haml/erb_tests.rb +0 -14
- data/test/haml/util_test.rb +32 -0
- data/test/test_helper.rb +0 -39
- metadata +96 -324
- data/bin/css2sass +0 -13
- data/bin/sass +0 -8
- data/bin/sass-convert +0 -7
- data/extra/haml-mode.el +0 -753
- data/extra/sass-mode.el +0 -207
- data/lib/haml/util/subset_map.rb +0 -101
- data/lib/sass.rb +0 -29
- data/lib/sass/callbacks.rb +0 -52
- data/lib/sass/css.rb +0 -294
- data/lib/sass/engine.rb +0 -720
- data/lib/sass/environment.rb +0 -143
- data/lib/sass/error.rb +0 -198
- data/lib/sass/files.rb +0 -160
- data/lib/sass/less.rb +0 -382
- data/lib/sass/plugin.rb +0 -279
- data/lib/sass/plugin/configuration.rb +0 -221
- data/lib/sass/plugin/generic.rb +0 -15
- data/lib/sass/plugin/merb.rb +0 -37
- data/lib/sass/plugin/rack.rb +0 -47
- data/lib/sass/plugin/rails.rb +0 -32
- data/lib/sass/plugin/staleness_checker.rb +0 -123
- data/lib/sass/repl.rb +0 -58
- data/lib/sass/script.rb +0 -63
- data/lib/sass/script/bool.rb +0 -18
- data/lib/sass/script/color.rb +0 -491
- data/lib/sass/script/css_lexer.rb +0 -29
- data/lib/sass/script/css_parser.rb +0 -31
- data/lib/sass/script/funcall.rb +0 -77
- data/lib/sass/script/functions.rb +0 -861
- data/lib/sass/script/interpolation.rb +0 -70
- data/lib/sass/script/lexer.rb +0 -337
- data/lib/sass/script/literal.rb +0 -236
- data/lib/sass/script/node.rb +0 -112
- data/lib/sass/script/number.rb +0 -423
- data/lib/sass/script/operation.rb +0 -95
- data/lib/sass/script/parser.rb +0 -401
- data/lib/sass/script/string.rb +0 -67
- data/lib/sass/script/string_interpolation.rb +0 -93
- data/lib/sass/script/unary_operation.rb +0 -57
- data/lib/sass/script/variable.rb +0 -48
- data/lib/sass/scss.rb +0 -17
- data/lib/sass/scss/css_parser.rb +0 -46
- data/lib/sass/scss/parser.rb +0 -855
- data/lib/sass/scss/rx.rb +0 -126
- data/lib/sass/scss/sass_parser.rb +0 -11
- data/lib/sass/scss/script_lexer.rb +0 -15
- data/lib/sass/scss/script_parser.rb +0 -25
- data/lib/sass/scss/static_parser.rb +0 -40
- data/lib/sass/selector.rb +0 -361
- data/lib/sass/selector/abstract_sequence.rb +0 -62
- data/lib/sass/selector/comma_sequence.rb +0 -82
- data/lib/sass/selector/sequence.rb +0 -237
- data/lib/sass/selector/simple.rb +0 -113
- data/lib/sass/selector/simple_sequence.rb +0 -136
- data/lib/sass/tree/charset_node.rb +0 -37
- data/lib/sass/tree/comment_node.rb +0 -128
- data/lib/sass/tree/debug_node.rb +0 -36
- data/lib/sass/tree/directive_node.rb +0 -75
- data/lib/sass/tree/extend_node.rb +0 -65
- data/lib/sass/tree/for_node.rb +0 -55
- data/lib/sass/tree/if_node.rb +0 -69
- data/lib/sass/tree/import_node.rb +0 -102
- data/lib/sass/tree/mixin_def_node.rb +0 -48
- data/lib/sass/tree/mixin_node.rb +0 -111
- data/lib/sass/tree/node.rb +0 -464
- data/lib/sass/tree/prop_node.rb +0 -220
- data/lib/sass/tree/root_node.rb +0 -163
- data/lib/sass/tree/rule_node.rb +0 -261
- data/lib/sass/tree/variable_node.rb +0 -39
- data/lib/sass/tree/warn_node.rb +0 -42
- data/lib/sass/tree/while_node.rb +0 -36
- data/test/haml/util/subset_map_test.rb +0 -91
- data/test/sass/callbacks_test.rb +0 -61
- data/test/sass/conversion_test.rb +0 -1218
- data/test/sass/css2sass_test.rb +0 -364
- data/test/sass/data/hsl-rgb.txt +0 -319
- data/test/sass/engine_test.rb +0 -2267
- data/test/sass/extend_test.rb +0 -1348
- data/test/sass/functions_test.rb +0 -556
- data/test/sass/less_conversion_test.rb +0 -653
- data/test/sass/more_results/more1.css +0 -9
- data/test/sass/more_results/more1_with_line_comments.css +0 -26
- data/test/sass/more_results/more_import.css +0 -29
- data/test/sass/more_templates/_more_partial.sass +0 -2
- data/test/sass/more_templates/more1.sass +0 -23
- data/test/sass/more_templates/more_import.sass +0 -11
- data/test/sass/plugin_test.rb +0 -433
- data/test/sass/results/alt.css +0 -4
- data/test/sass/results/basic.css +0 -9
- data/test/sass/results/compact.css +0 -5
- data/test/sass/results/complex.css +0 -86
- data/test/sass/results/compressed.css +0 -1
- data/test/sass/results/expanded.css +0 -19
- data/test/sass/results/import.css +0 -31
- data/test/sass/results/import_charset.css +0 -4
- data/test/sass/results/import_charset_1_8.css +0 -4
- data/test/sass/results/import_charset_ibm866.css +0 -4
- data/test/sass/results/line_numbers.css +0 -49
- data/test/sass/results/mixins.css +0 -95
- data/test/sass/results/multiline.css +0 -24
- data/test/sass/results/nested.css +0 -22
- data/test/sass/results/options.css +0 -1
- data/test/sass/results/parent_ref.css +0 -13
- data/test/sass/results/script.css +0 -16
- data/test/sass/results/scss_import.css +0 -31
- data/test/sass/results/scss_importee.css +0 -2
- data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
- data/test/sass/results/subdir/subdir.css +0 -3
- data/test/sass/results/units.css +0 -11
- data/test/sass/results/warn.css +0 -0
- data/test/sass/results/warn_imported.css +0 -0
- data/test/sass/script_conversion_test.rb +0 -314
- data/test/sass/script_test.rb +0 -470
- data/test/sass/scss/css_test.rb +0 -916
- data/test/sass/scss/rx_test.rb +0 -156
- data/test/sass/scss/scss_test.rb +0 -1122
- data/test/sass/scss/test_helper.rb +0 -37
- data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
- data/test/sass/templates/_imported_charset_utf8.sass +0 -4
- data/test/sass/templates/_partial.sass +0 -2
- data/test/sass/templates/alt.sass +0 -16
- data/test/sass/templates/basic.sass +0 -23
- data/test/sass/templates/bork1.sass +0 -2
- data/test/sass/templates/bork2.sass +0 -2
- data/test/sass/templates/bork3.sass +0 -2
- data/test/sass/templates/bork4.sass +0 -2
- data/test/sass/templates/compact.sass +0 -17
- data/test/sass/templates/complex.sass +0 -305
- data/test/sass/templates/compressed.sass +0 -15
- data/test/sass/templates/expanded.sass +0 -17
- data/test/sass/templates/import.sass +0 -12
- data/test/sass/templates/import_charset.sass +0 -7
- data/test/sass/templates/import_charset_1_8.sass +0 -4
- data/test/sass/templates/import_charset_ibm866.sass +0 -9
- data/test/sass/templates/importee.less +0 -2
- data/test/sass/templates/importee.sass +0 -19
- data/test/sass/templates/line_numbers.sass +0 -13
- data/test/sass/templates/mixin_bork.sass +0 -5
- data/test/sass/templates/mixins.sass +0 -76
- data/test/sass/templates/multiline.sass +0 -20
- data/test/sass/templates/nested.sass +0 -25
- data/test/sass/templates/nested_bork1.sass +0 -2
- data/test/sass/templates/nested_bork2.sass +0 -2
- data/test/sass/templates/nested_bork3.sass +0 -2
- data/test/sass/templates/nested_bork4.sass +0 -2
- data/test/sass/templates/nested_mixin_bork.sass +0 -6
- data/test/sass/templates/options.sass +0 -2
- data/test/sass/templates/parent_ref.sass +0 -25
- data/test/sass/templates/script.sass +0 -101
- data/test/sass/templates/scss_import.scss +0 -11
- data/test/sass/templates/scss_importee.scss +0 -1
- data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
- data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
- data/test/sass/templates/subdir/subdir.sass +0 -6
- data/test/sass/templates/units.sass +0 -11
- data/test/sass/templates/warn.sass +0 -3
- data/test/sass/templates/warn_imported.sass +0 -4
- data/vendor/fssm/LICENSE +0 -20
- data/vendor/fssm/README.markdown +0 -55
- data/vendor/fssm/Rakefile +0 -59
- data/vendor/fssm/VERSION.yml +0 -5
- data/vendor/fssm/example.rb +0 -9
- data/vendor/fssm/fssm.gemspec +0 -77
- data/vendor/fssm/lib/fssm.rb +0 -33
- data/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
- data/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
- data/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
- data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
- data/vendor/fssm/lib/fssm/monitor.rb +0 -26
- data/vendor/fssm/lib/fssm/path.rb +0 -91
- data/vendor/fssm/lib/fssm/pathname.rb +0 -502
- data/vendor/fssm/lib/fssm/state/directory.rb +0 -57
- data/vendor/fssm/lib/fssm/state/file.rb +0 -24
- data/vendor/fssm/lib/fssm/support.rb +0 -63
- data/vendor/fssm/lib/fssm/tree.rb +0 -176
- data/vendor/fssm/profile/prof-cache.rb +0 -40
- data/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
- data/vendor/fssm/profile/prof-pathname.rb +0 -68
- data/vendor/fssm/profile/prof-plain-pathname.html +0 -988
- data/vendor/fssm/profile/prof.html +0 -2379
- data/vendor/fssm/spec/path_spec.rb +0 -75
- data/vendor/fssm/spec/root/duck/quack.txt +0 -0
- data/vendor/fssm/spec/root/file.css +0 -0
- data/vendor/fssm/spec/root/file.rb +0 -0
- data/vendor/fssm/spec/root/file.yml +0 -0
- data/vendor/fssm/spec/root/moo/cow.txt +0 -0
- data/vendor/fssm/spec/spec_helper.rb +0 -14
@@ -1,136 +0,0 @@
|
|
1
|
-
module Sass
|
2
|
-
module Selector
|
3
|
-
# A unseparated sequence of selectors
|
4
|
-
# that all apply to a single element.
|
5
|
-
# For example, `.foo#bar[attr=baz]` is a simple sequence
|
6
|
-
# of the selectors `.foo`, `#bar`, and `[attr=baz]`.
|
7
|
-
class SimpleSequence < AbstractSequence
|
8
|
-
# The array of individual selectors.
|
9
|
-
#
|
10
|
-
# @return [Array<Simple>]
|
11
|
-
attr_reader :members
|
12
|
-
|
13
|
-
# Returns the element or universal selector in this sequence,
|
14
|
-
# if it exists.
|
15
|
-
#
|
16
|
-
# @return [Element, Universal, nil]
|
17
|
-
def base
|
18
|
-
@base ||= (members.first if members.first.is_a?(Element) || members.first.is_a?(Universal))
|
19
|
-
end
|
20
|
-
|
21
|
-
# Returns the non-base selectors in this sequence.
|
22
|
-
#
|
23
|
-
# @return [Set<Simple>]
|
24
|
-
def rest
|
25
|
-
@rest ||= Set.new(base ? members[1..-1] : members)
|
26
|
-
end
|
27
|
-
|
28
|
-
# @param selectors [Array<Simple>] See \{#members}
|
29
|
-
def initialize(selectors)
|
30
|
-
@members = selectors
|
31
|
-
end
|
32
|
-
|
33
|
-
# Resolves the {Parent} selectors within this selector
|
34
|
-
# by replacing them with the given parent selector,
|
35
|
-
# handling commas appropriately.
|
36
|
-
#
|
37
|
-
# @param super_seq [Sequence] The parent selector sequence
|
38
|
-
# @return [Array<SimpleSequence>] This selector, with parent references resolved.
|
39
|
-
# This is an array because the parent selector is itself a {Sequence}
|
40
|
-
# @raise [Sass::SyntaxError] If a parent selector is invalid
|
41
|
-
def resolve_parent_refs(super_seq)
|
42
|
-
# Parent selector only appears as the first selector in the sequence
|
43
|
-
return [self] unless @members.first.is_a?(Parent)
|
44
|
-
|
45
|
-
return super_seq.members if @members.size == 1
|
46
|
-
unless super_seq.members.last.is_a?(SimpleSequence)
|
47
|
-
raise Sass::SyntaxError.new("Invalid parent selector: " + super_seq.to_a.join)
|
48
|
-
end
|
49
|
-
|
50
|
-
super_seq.members[0...-1] +
|
51
|
-
[SimpleSequence.new(super_seq.members.last.members + @members[1..-1])]
|
52
|
-
end
|
53
|
-
|
54
|
-
# Non-destrucively extends this selector
|
55
|
-
# with the extensions specified in a hash
|
56
|
-
# (which should be populated via {Sass::Tree::Node#cssize}).
|
57
|
-
#
|
58
|
-
# @overload def do_extend(extends)
|
59
|
-
# @param extends [{Selector::Simple => Selector::Sequence}]
|
60
|
-
# The extensions to perform on this selector
|
61
|
-
# @return [Array<Sequence>] A list of selectors generated
|
62
|
-
# by extending this selector with `extends`.
|
63
|
-
# @see CommaSequence#do_extend
|
64
|
-
def do_extend(extends, seen = Set.new)
|
65
|
-
extends.get(members.to_set).map do |seq, sels|
|
66
|
-
# If A {@extend B} and C {...},
|
67
|
-
# seq is A, sels is B, and self is C
|
68
|
-
|
69
|
-
self_without_sel = self.members - sels
|
70
|
-
next unless unified = seq.members.last.unify(self_without_sel)
|
71
|
-
[sels, seq.members[0...-1] + [unified]]
|
72
|
-
end.compact.map do |sels, seq|
|
73
|
-
seq = Sequence.new(seq)
|
74
|
-
seen.include?(sels) ? [] : seq.do_extend(extends, seen + [sels])
|
75
|
-
end.flatten.uniq
|
76
|
-
end
|
77
|
-
|
78
|
-
# Unifies this selector with another {SimpleSequence}'s {SimpleSequence#members members array},
|
79
|
-
# returning another `SimpleSequence`
|
80
|
-
# that matches both this selector and the input selector.
|
81
|
-
#
|
82
|
-
# @param sels [Array<Simple>] A {SimpleSequence}'s {SimpleSequence#members members array}
|
83
|
-
# @return [SimpleSequence, nil] A {SimpleSequence} matching both `sels` and this selector,
|
84
|
-
# or `nil` if this is impossible (e.g. unifying `#foo` and `#bar`)
|
85
|
-
# @raise [Sass::SyntaxError] If this selector cannot be unified.
|
86
|
-
# This will only ever occur when a dynamic selector,
|
87
|
-
# such as {Parent} or {Interpolation}, is used in unification.
|
88
|
-
# Since these selectors should be resolved
|
89
|
-
# by the time extension and unification happen,
|
90
|
-
# this exception will only ever be raised as a result of programmer error
|
91
|
-
def unify(sels)
|
92
|
-
return unless sseq = members.inject(sels) do |sseq, sel|
|
93
|
-
return unless sseq
|
94
|
-
sel.unify(sseq)
|
95
|
-
end
|
96
|
-
SimpleSequence.new(sseq)
|
97
|
-
end
|
98
|
-
|
99
|
-
# Returns whether or not this selector matches all elements
|
100
|
-
# that the given selector matches (as well as possibly more).
|
101
|
-
#
|
102
|
-
# @example
|
103
|
-
# (.foo).superselector?(.foo.bar) #=> true
|
104
|
-
# (.foo).superselector?(.bar) #=> false
|
105
|
-
#
|
106
|
-
# @param sseq [SimpleSequence]
|
107
|
-
# @return [Boolean]
|
108
|
-
def superselector?(sseq)
|
109
|
-
(base.nil? || base.eql?(sseq.base)) && rest.subset?(sseq.rest)
|
110
|
-
end
|
111
|
-
|
112
|
-
# @see Simple#to_a
|
113
|
-
def to_a
|
114
|
-
@members.map {|sel| sel.to_a}.flatten
|
115
|
-
end
|
116
|
-
|
117
|
-
# Returns a string representation of the sequence.
|
118
|
-
# This is basically the selector string.
|
119
|
-
#
|
120
|
-
# @return [String]
|
121
|
-
def inspect
|
122
|
-
members.map {|m| m.inspect}.join
|
123
|
-
end
|
124
|
-
|
125
|
-
private
|
126
|
-
|
127
|
-
def _hash
|
128
|
-
[base, Haml::Util.set_hash(rest)].hash
|
129
|
-
end
|
130
|
-
|
131
|
-
def _eql?(other)
|
132
|
-
other.base.eql?(self.base) && Haml::Util.set_eql?(other.rest, self.rest)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Sass::Tree
|
2
|
-
# A static node representing an unproccessed Sass `@charset` directive.
|
3
|
-
#
|
4
|
-
# @see Sass::Tree
|
5
|
-
class CharsetNode < Node
|
6
|
-
# The name of the charset.
|
7
|
-
#
|
8
|
-
# @return [String]
|
9
|
-
attr_accessor :name
|
10
|
-
|
11
|
-
# @param name [String] see \{#name}
|
12
|
-
def initialize(name)
|
13
|
-
@name = name
|
14
|
-
super()
|
15
|
-
end
|
16
|
-
|
17
|
-
# @see Node#invisible?
|
18
|
-
def invisible?
|
19
|
-
!Haml::Util.ruby1_8?
|
20
|
-
end
|
21
|
-
|
22
|
-
protected
|
23
|
-
|
24
|
-
# @see Node#to_src
|
25
|
-
def to_src(tabs, opts, fmt)
|
26
|
-
"#{' ' * tabs}@charset \"#{name}\"#{semi fmt}\n"
|
27
|
-
end
|
28
|
-
|
29
|
-
# Computes the CSS for the directive.
|
30
|
-
#
|
31
|
-
# @param tabs [Fixnum] The level of indentation for the CSS
|
32
|
-
# @return [String] The resulting CSS
|
33
|
-
def _to_s(tabs)
|
34
|
-
"@charset \"#{name}\";"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
require 'sass/tree/node'
|
2
|
-
|
3
|
-
module Sass::Tree
|
4
|
-
# A static node representing a Sass comment (silent or loud).
|
5
|
-
#
|
6
|
-
# @see Sass::Tree
|
7
|
-
class CommentNode < Node
|
8
|
-
# The text of the comment, not including `/*` and `*/`.
|
9
|
-
#
|
10
|
-
# @return [String]
|
11
|
-
attr_accessor :value
|
12
|
-
|
13
|
-
# Whether or not the comment is silent (that is, doesn't output to CSS).
|
14
|
-
#
|
15
|
-
# @return [Boolean]
|
16
|
-
attr_accessor :silent
|
17
|
-
|
18
|
-
# @param value [String] See \{#value}
|
19
|
-
# @param silent [Boolean] See \{#silent}
|
20
|
-
def initialize(value, silent)
|
21
|
-
@lines = []
|
22
|
-
@value = normalize_indentation value
|
23
|
-
@silent = silent
|
24
|
-
super()
|
25
|
-
end
|
26
|
-
|
27
|
-
# Compares the contents of two comments.
|
28
|
-
#
|
29
|
-
# @param other [Object] The object to compare with
|
30
|
-
# @return [Boolean] Whether or not this node and the other object
|
31
|
-
# are the same
|
32
|
-
def ==(other)
|
33
|
-
self.class == other.class && value == other.value && silent == other.silent
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns `true` if this is a silent comment
|
37
|
-
# or the current style doesn't render comments.
|
38
|
-
#
|
39
|
-
# @return [Boolean]
|
40
|
-
def invisible?
|
41
|
-
style == :compressed || @silent
|
42
|
-
end
|
43
|
-
|
44
|
-
# @see Node#to_sass
|
45
|
-
def to_sass(tabs, opts = {})
|
46
|
-
content = value.gsub(/\*\/$/, '').rstrip
|
47
|
-
if content =~ /\A[ \t]/
|
48
|
-
# Re-indent SCSS comments like this:
|
49
|
-
# /* foo
|
50
|
-
# bar
|
51
|
-
# baz */
|
52
|
-
content.gsub!(/^/, ' ')
|
53
|
-
content.sub!(/\A([ \t]*)\/\*/, '/*\1')
|
54
|
-
end
|
55
|
-
|
56
|
-
content =
|
57
|
-
unless content.include?("\n")
|
58
|
-
content
|
59
|
-
else
|
60
|
-
content.gsub!(/\n( \*|\/\/)/, "\n ")
|
61
|
-
spaces = content.scan(/\n( *)/).map {|s| s.first.size}.min
|
62
|
-
sep = silent ? "\n//" : "\n *"
|
63
|
-
if spaces >= 2
|
64
|
-
content.gsub(/\n /, sep)
|
65
|
-
else
|
66
|
-
content.gsub(/\n#{' ' * spaces}/, sep)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
content.gsub!(/\A\/\*/, '//') if silent
|
71
|
-
content.gsub!(/^/, ' ' * tabs)
|
72
|
-
content.rstrip + "\n"
|
73
|
-
end
|
74
|
-
|
75
|
-
# @see Node#to_scss
|
76
|
-
def to_scss(tabs, opts = {})
|
77
|
-
spaces = (' ' * [tabs - value[/^ */].size, 0].max)
|
78
|
-
if silent
|
79
|
-
value.gsub(/^[\/ ]\*/, '//').gsub(/ *\*\/$/, '')
|
80
|
-
else
|
81
|
-
value
|
82
|
-
end.gsub(/^/, spaces) + "\n"
|
83
|
-
end
|
84
|
-
|
85
|
-
protected
|
86
|
-
|
87
|
-
# Computes the CSS for the comment.
|
88
|
-
#
|
89
|
-
# Returns `nil` if this is a silent comment
|
90
|
-
# or the current style doesn't render comments.
|
91
|
-
#
|
92
|
-
# @overload to_s(tabs = 0)
|
93
|
-
# @param tabs [Fixnum] The level of indentation for the CSS
|
94
|
-
# @return [String, nil] The resulting CSS
|
95
|
-
# @see #invisible?
|
96
|
-
def _to_s(tabs = 0, _ = nil)
|
97
|
-
return if invisible?
|
98
|
-
spaces = (' ' * [tabs - 1 - value[/^ */].size, 0].max)
|
99
|
-
|
100
|
-
content = value.gsub(/^/, spaces)
|
101
|
-
content.gsub!(/\n +(\* *(?!\/))?/, ' ') if style == :compact
|
102
|
-
content
|
103
|
-
end
|
104
|
-
|
105
|
-
# Removes this node from the tree if it's a silent comment.
|
106
|
-
#
|
107
|
-
# @param environment [Sass::Environment] The lexical environment containing
|
108
|
-
# variable and mixin values
|
109
|
-
# @return [Tree::Node, Array<Tree::Node>] The resulting static nodes
|
110
|
-
# @see Sass::Tree
|
111
|
-
def _perform(environment)
|
112
|
-
return [] if @silent
|
113
|
-
self
|
114
|
-
end
|
115
|
-
|
116
|
-
private
|
117
|
-
|
118
|
-
def normalize_indentation(str)
|
119
|
-
pre = str.split("\n").inject(str[/^[ \t]*/].split("")) do |pre, line|
|
120
|
-
line[/^[ \t]*/].split("").zip(pre).inject([]) do |arr, (a, b)|
|
121
|
-
break arr if a != b
|
122
|
-
arr + [a]
|
123
|
-
end
|
124
|
-
end.join
|
125
|
-
str.gsub(/^#{pre}/, '')
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
data/lib/sass/tree/debug_node.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
module Sass
|
2
|
-
module Tree
|
3
|
-
# A dynamic node representing a Sass `@debug` statement.
|
4
|
-
#
|
5
|
-
# @see Sass::Tree
|
6
|
-
class DebugNode < Node
|
7
|
-
# @param expr [Script::Node] The expression to print
|
8
|
-
def initialize(expr)
|
9
|
-
@expr = expr
|
10
|
-
super()
|
11
|
-
end
|
12
|
-
|
13
|
-
protected
|
14
|
-
|
15
|
-
# @see Node#to_src
|
16
|
-
def to_src(tabs, opts, fmt)
|
17
|
-
"#{' ' * tabs}@debug #{@expr.to_sass(opts)}#{semi fmt}\n"
|
18
|
-
end
|
19
|
-
|
20
|
-
# Prints the expression to STDERR.
|
21
|
-
#
|
22
|
-
# @param environment [Sass::Environment] The lexical environment containing
|
23
|
-
# variable and mixin values
|
24
|
-
def _perform(environment)
|
25
|
-
res = @expr.perform(environment)
|
26
|
-
res = res.value if res.is_a?(Sass::Script::String)
|
27
|
-
if filename
|
28
|
-
$stderr.puts "#{filename}:#{line} DEBUG: #{res}"
|
29
|
-
else
|
30
|
-
$stderr.puts "Line #{line} DEBUG: #{res}"
|
31
|
-
end
|
32
|
-
[]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
module Sass::Tree
|
2
|
-
# A static node representing an unproccessed Sass `@`-directive.
|
3
|
-
# Directives known to Sass, like `@for` and `@debug`,
|
4
|
-
# are handled by their own nodes;
|
5
|
-
# only CSS directives like `@media` and `@font-face` become {DirectiveNode}s.
|
6
|
-
#
|
7
|
-
# `@import` and `@charset` are special cases;
|
8
|
-
# they become {ImportNode}s and {CharsetNode}s, respectively.
|
9
|
-
#
|
10
|
-
# @see Sass::Tree
|
11
|
-
class DirectiveNode < Node
|
12
|
-
# The text of the directive, `@` and all.
|
13
|
-
#
|
14
|
-
# @return [String]
|
15
|
-
attr_accessor :value
|
16
|
-
|
17
|
-
# @param value [String] See \{#value}
|
18
|
-
def initialize(value)
|
19
|
-
@value = value
|
20
|
-
super()
|
21
|
-
end
|
22
|
-
|
23
|
-
protected
|
24
|
-
|
25
|
-
# @see Node#to_src
|
26
|
-
def to_src(tabs, opts, fmt)
|
27
|
-
res = "#{' ' * tabs}#{value}"
|
28
|
-
return res + "#{semi fmt}\n" unless has_children
|
29
|
-
res + children_to_src(tabs, opts, fmt) + "\n"
|
30
|
-
end
|
31
|
-
|
32
|
-
# Computes the CSS for the directive.
|
33
|
-
#
|
34
|
-
# @param tabs [Fixnum] The level of indentation for the CSS
|
35
|
-
# @return [String] The resulting CSS
|
36
|
-
def _to_s(tabs)
|
37
|
-
return value + ";" unless has_children
|
38
|
-
return value + " {}" if children.empty?
|
39
|
-
result = if style == :compressed
|
40
|
-
"#{value}{"
|
41
|
-
else
|
42
|
-
"#{' ' * (tabs - 1)}#{value} {" + (style == :compact ? ' ' : "\n")
|
43
|
-
end
|
44
|
-
was_prop = false
|
45
|
-
first = true
|
46
|
-
children.each do |child|
|
47
|
-
next if child.invisible?
|
48
|
-
if style == :compact
|
49
|
-
if child.is_a?(PropNode)
|
50
|
-
result << "#{child.to_s(first || was_prop ? 1 : tabs + 1)} "
|
51
|
-
else
|
52
|
-
if was_prop
|
53
|
-
result[-1] = "\n"
|
54
|
-
end
|
55
|
-
rendered = child.to_s(tabs + 1).dup
|
56
|
-
rendered = rendered.lstrip if first
|
57
|
-
result << rendered.rstrip + "\n"
|
58
|
-
end
|
59
|
-
was_prop = child.is_a?(PropNode)
|
60
|
-
first = false
|
61
|
-
elsif style == :compressed
|
62
|
-
result << (was_prop ? ";#{child.to_s(1)}" : child.to_s(1))
|
63
|
-
was_prop = child.is_a?(PropNode)
|
64
|
-
else
|
65
|
-
result << child.to_s(tabs + 1) + "\n"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
result.rstrip + if style == :compressed
|
69
|
-
"}"
|
70
|
-
else
|
71
|
-
(style == :expanded ? "\n" : " ") + "}\n"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'sass/tree/node'
|
2
|
-
|
3
|
-
module Sass::Tree
|
4
|
-
# A static node reprenting an `@extend` directive.
|
5
|
-
#
|
6
|
-
# @see Sass::Tree
|
7
|
-
class ExtendNode < Node
|
8
|
-
# @param selector [Array<String, Sass::Script::Node>]
|
9
|
-
# The CSS selector to extend,
|
10
|
-
# interspersed with {Sass::Script::Node}s
|
11
|
-
# representing `#{}`-interpolation.
|
12
|
-
def initialize(selector)
|
13
|
-
@selector = selector
|
14
|
-
super()
|
15
|
-
end
|
16
|
-
|
17
|
-
# Registers this extension in the `extends` subset map.
|
18
|
-
#
|
19
|
-
# @param extends [Haml::Util::SubsetMap{Selector::Simple => Selector::Sequence}]
|
20
|
-
# The extensions defined for this tree
|
21
|
-
# @param parent [RuleNode] The parent node of this node
|
22
|
-
# @see Node#cssize
|
23
|
-
def cssize(extends, parent)
|
24
|
-
@resolved_selector.members.each do |seq|
|
25
|
-
if seq.members.size > 1
|
26
|
-
raise Sass::SyntaxError.new("Can't extend #{seq.to_a.join}: can't extend nested selectors")
|
27
|
-
end
|
28
|
-
|
29
|
-
sseq = seq.members.first
|
30
|
-
if !sseq.is_a?(Sass::Selector::SimpleSequence)
|
31
|
-
raise Sass::SyntaxError.new("Can't extend #{seq.to_a.join}: invalid selector")
|
32
|
-
end
|
33
|
-
|
34
|
-
sel = sseq.members
|
35
|
-
parent.resolved_rules.members.each do |seq|
|
36
|
-
if !seq.members.last.is_a?(Sass::Selector::SimpleSequence)
|
37
|
-
raise Sass::SyntaxError.new("#{seq} can't extend: invalid selector")
|
38
|
-
end
|
39
|
-
|
40
|
-
extends[sel] = seq
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
[]
|
45
|
-
end
|
46
|
-
|
47
|
-
protected
|
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
|
-
|
54
|
-
# Runs SassScript interpolation in the selector,
|
55
|
-
# and then parses the result into a {Sass::Selector::CommaSequence}.
|
56
|
-
#
|
57
|
-
# @param environment [Sass::Environment] The lexical environment containing
|
58
|
-
# variable and mixin values
|
59
|
-
def perform!(environment)
|
60
|
-
@resolved_selector = Sass::SCSS::CssParser.new(run_interp(@selector, environment), self.line).
|
61
|
-
parse_selector(self.filename)
|
62
|
-
super
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|