haml-edge 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/EDGE_GEM_VERSION +1 -0
  2. data/FAQ +138 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.rdoc +332 -0
  5. data/REVISION +1 -0
  6. data/Rakefile +226 -0
  7. data/VERSION +1 -0
  8. data/bin/css2sass +7 -0
  9. data/bin/haml +9 -0
  10. data/bin/html2haml +7 -0
  11. data/bin/sass +8 -0
  12. data/extra/edge_gem_watch.rb +13 -0
  13. data/extra/haml-mode.el +596 -0
  14. data/extra/sass-mode.el +200 -0
  15. data/init.rb +8 -0
  16. data/lib/haml/buffer.rb +255 -0
  17. data/lib/haml/engine.rb +268 -0
  18. data/lib/haml/error.rb +22 -0
  19. data/lib/haml/exec.rb +395 -0
  20. data/lib/haml/filters.rb +275 -0
  21. data/lib/haml/helpers/action_view_extensions.rb +45 -0
  22. data/lib/haml/helpers/action_view_mods.rb +181 -0
  23. data/lib/haml/helpers.rb +488 -0
  24. data/lib/haml/html.rb +222 -0
  25. data/lib/haml/precompiler.rb +904 -0
  26. data/lib/haml/shared.rb +45 -0
  27. data/lib/haml/template/patch.rb +58 -0
  28. data/lib/haml/template/plugin.rb +72 -0
  29. data/lib/haml/template.rb +42 -0
  30. data/lib/haml/util.rb +88 -0
  31. data/lib/haml/version.rb +47 -0
  32. data/lib/haml.rb +1044 -0
  33. data/lib/sass/css.rb +388 -0
  34. data/lib/sass/engine.rb +495 -0
  35. data/lib/sass/environment.rb +46 -0
  36. data/lib/sass/error.rb +35 -0
  37. data/lib/sass/plugin/merb.rb +56 -0
  38. data/lib/sass/plugin/rails.rb +24 -0
  39. data/lib/sass/plugin.rb +204 -0
  40. data/lib/sass/repl.rb +51 -0
  41. data/lib/sass/script/bool.rb +13 -0
  42. data/lib/sass/script/color.rb +97 -0
  43. data/lib/sass/script/funcall.rb +29 -0
  44. data/lib/sass/script/functions.rb +134 -0
  45. data/lib/sass/script/lexer.rb +148 -0
  46. data/lib/sass/script/literal.rb +82 -0
  47. data/lib/sass/script/number.rb +231 -0
  48. data/lib/sass/script/operation.rb +30 -0
  49. data/lib/sass/script/parser.rb +142 -0
  50. data/lib/sass/script/string.rb +9 -0
  51. data/lib/sass/script/unary_operation.rb +21 -0
  52. data/lib/sass/script/variable.rb +20 -0
  53. data/lib/sass/script.rb +38 -0
  54. data/lib/sass/tree/attr_node.rb +64 -0
  55. data/lib/sass/tree/comment_node.rb +30 -0
  56. data/lib/sass/tree/debug_node.rb +22 -0
  57. data/lib/sass/tree/directive_node.rb +50 -0
  58. data/lib/sass/tree/file_node.rb +27 -0
  59. data/lib/sass/tree/for_node.rb +29 -0
  60. data/lib/sass/tree/if_node.rb +27 -0
  61. data/lib/sass/tree/mixin_def_node.rb +18 -0
  62. data/lib/sass/tree/mixin_node.rb +35 -0
  63. data/lib/sass/tree/node.rb +99 -0
  64. data/lib/sass/tree/rule_node.rb +161 -0
  65. data/lib/sass/tree/variable_node.rb +24 -0
  66. data/lib/sass/tree/while_node.rb +21 -0
  67. data/lib/sass.rb +1062 -0
  68. data/rails/init.rb +1 -0
  69. data/test/benchmark.rb +99 -0
  70. data/test/haml/engine_test.rb +795 -0
  71. data/test/haml/helper_test.rb +228 -0
  72. data/test/haml/html2haml_test.rb +108 -0
  73. data/test/haml/markaby/standard.mab +52 -0
  74. data/test/haml/mocks/article.rb +6 -0
  75. data/test/haml/results/content_for_layout.xhtml +15 -0
  76. data/test/haml/results/eval_suppressed.xhtml +9 -0
  77. data/test/haml/results/filters.xhtml +62 -0
  78. data/test/haml/results/helpers.xhtml +93 -0
  79. data/test/haml/results/helpful.xhtml +10 -0
  80. data/test/haml/results/just_stuff.xhtml +68 -0
  81. data/test/haml/results/list.xhtml +12 -0
  82. data/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
  83. data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
  84. data/test/haml/results/original_engine.xhtml +20 -0
  85. data/test/haml/results/partial_layout.xhtml +5 -0
  86. data/test/haml/results/partials.xhtml +21 -0
  87. data/test/haml/results/render_layout.xhtml +3 -0
  88. data/test/haml/results/silent_script.xhtml +74 -0
  89. data/test/haml/results/standard.xhtml +162 -0
  90. data/test/haml/results/tag_parsing.xhtml +23 -0
  91. data/test/haml/results/very_basic.xhtml +5 -0
  92. data/test/haml/results/whitespace_handling.xhtml +89 -0
  93. data/test/haml/rhtml/_av_partial_1.rhtml +12 -0
  94. data/test/haml/rhtml/_av_partial_2.rhtml +8 -0
  95. data/test/haml/rhtml/action_view.rhtml +62 -0
  96. data/test/haml/rhtml/standard.rhtml +54 -0
  97. data/test/haml/template_test.rb +204 -0
  98. data/test/haml/templates/_av_partial_1.haml +9 -0
  99. data/test/haml/templates/_av_partial_1_ugly.haml +9 -0
  100. data/test/haml/templates/_av_partial_2.haml +5 -0
  101. data/test/haml/templates/_av_partial_2_ugly.haml +5 -0
  102. data/test/haml/templates/_layout.erb +3 -0
  103. data/test/haml/templates/_layout_for_partial.haml +3 -0
  104. data/test/haml/templates/_partial.haml +8 -0
  105. data/test/haml/templates/_text_area.haml +3 -0
  106. data/test/haml/templates/action_view.haml +47 -0
  107. data/test/haml/templates/action_view_ugly.haml +47 -0
  108. data/test/haml/templates/breakage.haml +8 -0
  109. data/test/haml/templates/content_for_layout.haml +10 -0
  110. data/test/haml/templates/eval_suppressed.haml +11 -0
  111. data/test/haml/templates/filters.haml +66 -0
  112. data/test/haml/templates/helpers.haml +95 -0
  113. data/test/haml/templates/helpful.haml +11 -0
  114. data/test/haml/templates/just_stuff.haml +83 -0
  115. data/test/haml/templates/list.haml +12 -0
  116. data/test/haml/templates/nuke_inner_whitespace.haml +32 -0
  117. data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
  118. data/test/haml/templates/original_engine.haml +17 -0
  119. data/test/haml/templates/partial_layout.haml +3 -0
  120. data/test/haml/templates/partialize.haml +1 -0
  121. data/test/haml/templates/partials.haml +12 -0
  122. data/test/haml/templates/render_layout.haml +2 -0
  123. data/test/haml/templates/silent_script.haml +40 -0
  124. data/test/haml/templates/standard.haml +42 -0
  125. data/test/haml/templates/standard_ugly.haml +42 -0
  126. data/test/haml/templates/tag_parsing.haml +21 -0
  127. data/test/haml/templates/very_basic.haml +4 -0
  128. data/test/haml/templates/whitespace_handling.haml +87 -0
  129. data/test/haml/util_test.rb +87 -0
  130. data/test/linked_rails.rb +12 -0
  131. data/test/sass/css2sass_test.rb +193 -0
  132. data/test/sass/engine_test.rb +709 -0
  133. data/test/sass/functions_test.rb +109 -0
  134. data/test/sass/more_results/more1.css +9 -0
  135. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  136. data/test/sass/more_results/more_import.css +29 -0
  137. data/test/sass/more_templates/_more_partial.sass +2 -0
  138. data/test/sass/more_templates/more1.sass +23 -0
  139. data/test/sass/more_templates/more_import.sass +11 -0
  140. data/test/sass/plugin_test.rb +213 -0
  141. data/test/sass/results/alt.css +4 -0
  142. data/test/sass/results/basic.css +9 -0
  143. data/test/sass/results/compact.css +5 -0
  144. data/test/sass/results/complex.css +87 -0
  145. data/test/sass/results/compressed.css +1 -0
  146. data/test/sass/results/expanded.css +19 -0
  147. data/test/sass/results/import.css +29 -0
  148. data/test/sass/results/line_numbers.css +49 -0
  149. data/test/sass/results/mixins.css +95 -0
  150. data/test/sass/results/multiline.css +24 -0
  151. data/test/sass/results/nested.css +22 -0
  152. data/test/sass/results/parent_ref.css +13 -0
  153. data/test/sass/results/script.css +16 -0
  154. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  155. data/test/sass/results/subdir/subdir.css +3 -0
  156. data/test/sass/results/units.css +11 -0
  157. data/test/sass/script_test.rb +250 -0
  158. data/test/sass/templates/_partial.sass +2 -0
  159. data/test/sass/templates/alt.sass +16 -0
  160. data/test/sass/templates/basic.sass +23 -0
  161. data/test/sass/templates/bork.sass +2 -0
  162. data/test/sass/templates/bork2.sass +2 -0
  163. data/test/sass/templates/compact.sass +17 -0
  164. data/test/sass/templates/complex.sass +309 -0
  165. data/test/sass/templates/compressed.sass +15 -0
  166. data/test/sass/templates/expanded.sass +17 -0
  167. data/test/sass/templates/import.sass +11 -0
  168. data/test/sass/templates/importee.sass +19 -0
  169. data/test/sass/templates/line_numbers.sass +13 -0
  170. data/test/sass/templates/mixins.sass +76 -0
  171. data/test/sass/templates/multiline.sass +20 -0
  172. data/test/sass/templates/nested.sass +25 -0
  173. data/test/sass/templates/parent_ref.sass +25 -0
  174. data/test/sass/templates/script.sass +101 -0
  175. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  176. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  177. data/test/sass/templates/subdir/subdir.sass +6 -0
  178. data/test/sass/templates/units.sass +11 -0
  179. data/test/test_helper.rb +21 -0
  180. metadata +278 -0
@@ -0,0 +1,50 @@
1
+ module Sass::Tree
2
+ class DirectiveNode < Node
3
+ attr_accessor :value
4
+
5
+ def initialize(value, options)
6
+ @value = value
7
+ super(options)
8
+ end
9
+
10
+ def to_s(tabs)
11
+ if children.empty?
12
+ value + ";"
13
+ else
14
+ result = if @style == :compressed
15
+ "#{value}{"
16
+ else
17
+ "#{' ' * (tabs - 1)}#{value} {" + (@style == :compact ? ' ' : "\n")
18
+ end
19
+ was_attr = false
20
+ first = true
21
+ children.each do |child|
22
+ if @style == :compact
23
+ if child.is_a?(AttrNode)
24
+ result << "#{child.to_s(first || was_attr ? 1 : tabs + 1)} "
25
+ else
26
+ if was_attr
27
+ result[-1] = "\n"
28
+ end
29
+ rendered = child.to_s(tabs + 1)
30
+ rendered.lstrip! if first
31
+ result << rendered
32
+ end
33
+ was_attr = child.is_a?(AttrNode)
34
+ first = false
35
+ elsif @style == :compressed
36
+ result << (was_attr ? ";#{child.to_s(1)}" : child.to_s(1))
37
+ was_attr = child.is_a?(AttrNode)
38
+ else
39
+ result << child.to_s(tabs + 1) + "\n"
40
+ end
41
+ end
42
+ result.rstrip + if @style == :compressed
43
+ "}"
44
+ else
45
+ (@style == :expanded ? "\n" : " ") + "}\n"
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,27 @@
1
+ module Sass
2
+ module Tree
3
+ class FileNode < Node
4
+ def initialize(filename, children, options)
5
+ @filename = filename
6
+ super(options)
7
+ self.children = children
8
+ end
9
+
10
+ def to_s(*args)
11
+ super()
12
+ rescue Sass::SyntaxError => e
13
+ e.add_backtrace_entry(@filename)
14
+ raise e
15
+ end
16
+
17
+ protected
18
+
19
+ def perform!(environment)
20
+ self.children = perform_children(environment)
21
+ rescue Sass::SyntaxError => e
22
+ e.add_backtrace_entry(@filename)
23
+ raise e
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,29 @@
1
+ require 'sass/tree/node'
2
+
3
+ module Sass::Tree
4
+ class ForNode < Node
5
+ def initialize(var, from, to, exclusive, options)
6
+ @var = var
7
+ @from = from
8
+ @to = to
9
+ @exclusive = exclusive
10
+ super(options)
11
+ end
12
+
13
+ protected
14
+
15
+ def _perform(environment)
16
+ from = @from.perform(environment).to_i
17
+ to = @to.perform(environment).to_i
18
+ range = Range.new(from, to, @exclusive)
19
+
20
+ children = []
21
+ environment = Sass::Environment.new(environment)
22
+ range.each do |i|
23
+ environment.set_local_var(@var, Sass::Script::Number.new(i))
24
+ children += perform_children(environment)
25
+ end
26
+ children
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ require 'sass/tree/node'
2
+
3
+ module Sass::Tree
4
+ class IfNode < Node
5
+ attr_accessor :else
6
+
7
+ def initialize(expr, options)
8
+ @expr = expr
9
+ @last_else = self
10
+ super(options)
11
+ end
12
+
13
+ def add_else(node)
14
+ @last_else.else = node
15
+ @last_else = node
16
+ end
17
+
18
+ protected
19
+
20
+ def _perform(environment)
21
+ environment = Sass::Environment.new(environment)
22
+ return perform_children(environment) if @expr.nil? || @expr.perform(environment).to_bool
23
+ return @else.perform(environment) if @else
24
+ []
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ module Sass
2
+ module Tree
3
+ class MixinDefNode < Node
4
+ def initialize(name, args, options)
5
+ @name = name
6
+ @args = args
7
+ super(options)
8
+ end
9
+
10
+ private
11
+
12
+ def _perform(environment)
13
+ environment.set_mixin(@name, Sass::Mixin.new(@name, @args, environment, children))
14
+ []
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,35 @@
1
+ require 'sass/tree/node'
2
+
3
+ module Sass::Tree
4
+ class MixinNode < Node
5
+ def initialize(name, args, options)
6
+ @name = name
7
+ @args = args
8
+ super(options)
9
+ end
10
+
11
+ protected
12
+
13
+ def _perform(environment)
14
+ raise Sass::SyntaxError.new("Undefined mixin '#{@name}'.", @line) unless mixin = environment.mixin(@name)
15
+
16
+ raise Sass::SyntaxError.new(<<END.gsub("\n", "")) if mixin.args.size < @args.size
17
+ Mixin #{@name} takes #{mixin.args.size} argument#{'s' if mixin.args.size != 1}
18
+ but #{@args.size} #{@args.size == 1 ? 'was' : 'were'} passed.
19
+ END
20
+
21
+ environment = mixin.args.zip(@args).
22
+ inject(Sass::Environment.new(mixin.environment)) do |env, ((name, default), value)|
23
+ env.set_local_var(name,
24
+ if value
25
+ value.perform(environment)
26
+ elsif default
27
+ default.perform(env)
28
+ end)
29
+ raise Sass::SyntaxError.new("Mixin #{@name} is missing parameter !#{name}.") unless env.var(name)
30
+ env
31
+ end
32
+ mixin.tree.map {|c| c.perform(environment)}.flatten
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,99 @@
1
+ module Sass
2
+ module Tree
3
+ class Node
4
+ attr_accessor :children
5
+ attr_accessor :line
6
+ attr_accessor :filename
7
+
8
+ def initialize(options)
9
+ @options = options
10
+ @style = options[:style]
11
+ @children = []
12
+ end
13
+
14
+ def <<(child)
15
+ if msg = invalid_child?(child)
16
+ raise Sass::SyntaxError.new(msg, child.line)
17
+ end
18
+ @children << child
19
+ end
20
+
21
+ # We need this because Node duck types as an Array in engine.rb
22
+ def last
23
+ children.last
24
+ end
25
+
26
+ def ==(other)
27
+ self.class == other.class && other.children == children
28
+ end
29
+
30
+ def to_s
31
+ result = String.new
32
+ children.each do |child|
33
+ if child.is_a? AttrNode
34
+ raise Sass::SyntaxError.new('Attributes aren\'t allowed at the root of a document.', child.line)
35
+ else
36
+ child_str = child.to_s(1)
37
+ next unless child_str && child_str.length > 0
38
+ result << child_str + (@style == :compressed ? '' : "\n")
39
+ end
40
+ end
41
+ @style == :compressed ? result+"\n" : result[0...-1]
42
+ end
43
+
44
+ def perform(environment)
45
+ _perform(environment)
46
+ rescue Sass::SyntaxError => e
47
+ e.sass_line ||= line
48
+ raise e
49
+ end
50
+
51
+ protected
52
+
53
+ def _perform(environment)
54
+ node = dup
55
+ node.perform!(environment)
56
+ node
57
+ end
58
+
59
+ def perform!(environment)
60
+ self.children = perform_children(Environment.new(environment))
61
+ end
62
+
63
+ def perform_children(environment)
64
+ children.map {|c| c.perform(environment)}.flatten
65
+ end
66
+
67
+ def interpolate(text, environment)
68
+ res = ''
69
+ rest = Haml::Shared.handle_interpolation text do |scan|
70
+ escapes = scan[2].size
71
+ res << scan.matched[0...-2 - escapes]
72
+ if escapes % 2 == 1
73
+ res << "\\" * (escapes - 1) << '#{'
74
+ else
75
+ res << "\\" * [0, escapes - 1].max
76
+ res << Script::Parser.new(scan, line, scan.pos - scan.matched_size, filename).
77
+ parse_interpolated.perform(environment).to_s
78
+ end
79
+ end
80
+ res + rest
81
+ end
82
+
83
+ def balance(*args)
84
+ res = Haml::Shared.balance(*args)
85
+ return res if res
86
+ raise Sass::SyntaxError.new("Unbalanced brackets.", line)
87
+ end
88
+
89
+ private
90
+
91
+ # This method should be overridden by subclasses to return an error message
92
+ # if the given child node is invalid,
93
+ # and false or nil otherwise.
94
+ def invalid_child?(child)
95
+ false
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,161 @@
1
+ require 'pathname'
2
+
3
+ module Sass::Tree
4
+ class RuleNode < Node
5
+ # The character used to include the parent selector
6
+ PARENT = '&'
7
+
8
+ attr_accessor :rules
9
+
10
+ def initialize(rule, options)
11
+ @rules = [rule]
12
+ super(options)
13
+ end
14
+
15
+ def ==(other)
16
+ self.class == other.class && rules == other.rules && super
17
+ end
18
+
19
+ def add_rules(node)
20
+ @rules += node.rules
21
+ end
22
+
23
+ def continued?
24
+ @rules.last[-1] == ?,
25
+ end
26
+
27
+ def to_s(tabs, super_rules = nil)
28
+ resolve_parent_refs!(super_rules)
29
+
30
+ attributes = []
31
+ sub_rules = []
32
+
33
+ rule_separator = @style == :compressed ? ',' : ', '
34
+ line_separator = [:nested, :expanded].include?(@style) ? ",\n" : rule_separator
35
+ rule_indent = ' ' * (tabs - 1)
36
+ per_rule_indent, total_indent = [:nested, :expanded].include?(@style) ? [rule_indent, ''] : ['', rule_indent]
37
+
38
+ total_rule = total_indent + @rules.map do |line|
39
+ per_rule_indent + line.join(rule_separator)
40
+ end.join(line_separator)
41
+
42
+ children.each do |child|
43
+ if child.is_a? RuleNode
44
+ sub_rules << child
45
+ else
46
+ attributes << child
47
+ end
48
+ end
49
+
50
+ to_return = ''
51
+ if !attributes.empty?
52
+ old_spaces = ' ' * (tabs - 1)
53
+ spaces = ' ' * tabs
54
+ if @options[:line_comments] && @style != :compressed
55
+ to_return << "#{old_spaces}/* line #{line}"
56
+
57
+ if filename
58
+ relative_filename = if @options[:css_filename]
59
+ begin
60
+ Pathname.new(filename).relative_path_from(
61
+ Pathname.new(File.dirname(@options[:css_filename]))).to_s
62
+ rescue ArgumentError
63
+ nil
64
+ end
65
+ end
66
+ relative_filename ||= filename
67
+ to_return << ", #{relative_filename}"
68
+ end
69
+
70
+ to_return << " */\n"
71
+ end
72
+
73
+ if @style == :compact
74
+ attributes = attributes.map { |a| a.to_s(1) }.select{|a| a && a.length > 0}.join(' ')
75
+ to_return << "#{total_rule} { #{attributes} }\n"
76
+ elsif @style == :compressed
77
+ attributes = attributes.map { |a| a.to_s(1) }.select{|a| a && a.length > 0}.join(';')
78
+ to_return << "#{total_rule}{#{attributes}}"
79
+ else
80
+ attributes = attributes.map { |a| a.to_s(tabs + 1) }.select{|a| a && a.length > 0}.join("\n")
81
+ end_attrs = (@style == :expanded ? "\n" + old_spaces : ' ')
82
+ to_return << "#{total_rule} {\n#{attributes}#{end_attrs}}\n"
83
+ end
84
+ end
85
+
86
+ tabs += 1 unless attributes.empty? || @style != :nested
87
+ sub_rules.each do |sub|
88
+ to_return << sub.to_s(tabs, @rules)
89
+ end
90
+
91
+ to_return
92
+ end
93
+
94
+ protected
95
+
96
+ def resolve_parent_refs!(super_rules)
97
+ if super_rules.nil?
98
+ @rules.each do |line|
99
+ line.map! do |rule|
100
+ if rule.include?(:parent)
101
+ raise Sass::SyntaxError.new("Base-level rules cannot contain the parent-selector-referencing character '#{PARENT}'.", self.line)
102
+ end
103
+
104
+ rule.join
105
+ end.compact!
106
+ end
107
+ return
108
+ end
109
+
110
+ new_rules = []
111
+ super_rules.each do |super_line|
112
+ @rules.each do |line|
113
+ new_rules << []
114
+
115
+ super_line.each do |super_rule|
116
+ line.each do |rule|
117
+ rule.unshift(:parent, " ") unless rule.include?(:parent)
118
+
119
+ new_rules.last << rule.map do |segment|
120
+ next segment unless segment == :parent
121
+ super_rule
122
+ end.join
123
+ end
124
+ end
125
+ end
126
+ end
127
+ @rules = new_rules
128
+ end
129
+
130
+ def perform!(environment)
131
+ @rules = @rules.map {|r| parse_selector(interpolate(r, environment))}
132
+ super
133
+ end
134
+
135
+ def parse_selector(text)
136
+ scanner = StringScanner.new(text)
137
+ rules = [[]]
138
+
139
+ while scanner.rest?
140
+ rules.last << scanner.scan(/[^",&]*/)
141
+ case scanner.scan(/./)
142
+ when '&'; rules.last << :parent
143
+ when ','
144
+ scanner.scan(/\s*/)
145
+ rules << [] if scanner.rest?
146
+ when '"'
147
+ rules.last << '"' << scanner.scan(/([^"\\]|\\.)*/)
148
+ # We don't want to enforce that strings are closed,
149
+ # but we do want to consume quotes or trailing backslashes.
150
+ rules.last << scanner.scan(/./) if scanner.rest?
151
+ end
152
+ end
153
+
154
+ rules.map! do |l|
155
+ Haml::Util.merge_adjacent_strings(l).reject {|r| r.is_a?(String) && r.empty?}
156
+ end
157
+
158
+ rules
159
+ end
160
+ end
161
+ end
@@ -0,0 +1,24 @@
1
+ module Sass
2
+ module Tree
3
+ class VariableNode < Node
4
+ def initialize(name, expr, guarded, options)
5
+ @name = name
6
+ @expr = expr
7
+ @guarded = guarded
8
+ super(options)
9
+ end
10
+
11
+ protected
12
+
13
+ def _perform(environment)
14
+ if @guarded && environment.var(@name).nil?
15
+ environment.set_var(@name, @expr.perform(environment))
16
+ elsif !@guarded
17
+ environment.set_var(@name, @expr.perform(environment))
18
+ end
19
+
20
+ []
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ require 'sass/tree/node'
2
+
3
+ module Sass::Tree
4
+ class WhileNode < Node
5
+ def initialize(expr, options)
6
+ @expr = expr
7
+ super(options)
8
+ end
9
+
10
+ private
11
+
12
+ def _perform(environment)
13
+ children = []
14
+ new_environment = Sass::Environment.new(environment)
15
+ while @expr.perform(environment).to_bool
16
+ children += perform_children(new_environment)
17
+ end
18
+ children
19
+ end
20
+ end
21
+ end