haml 3.0.23 → 3.0.24
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/VERSION +1 -1
- data/lib/haml/exec.rb +10 -1
- data/lib/haml/html.rb +7 -7
- data/lib/haml/util.rb +18 -1
- data/lib/sass/scss/parser.rb +11 -2
- data/test/haml/html2haml/erb_tests.rb +14 -0
- data/test/sass/scss/scss_test.rb +14 -0
- data/test/test_helper.rb +8 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.24
|
data/lib/haml/exec.rb
CHANGED
@@ -124,9 +124,18 @@ module Haml
|
|
124
124
|
# @param color [Symbol] The name of the color to use for this action.
|
125
125
|
# Can be `:red`, `:green`, or `:yellow`.
|
126
126
|
def puts_action(name, color, arg)
|
127
|
+
return if @options[:for_engine][:quiet]
|
127
128
|
printf color(color, "%11s %s\n"), name, arg
|
128
129
|
end
|
129
130
|
|
131
|
+
# Same as \{Kernel.puts}, but doesn't print anything if the `--quiet` option is set.
|
132
|
+
#
|
133
|
+
# @param args [Array] Passed on to \{Kernel.puts}
|
134
|
+
def puts(*args)
|
135
|
+
return if @options[:for_engine][:quiet]
|
136
|
+
Kernel.puts(*args)
|
137
|
+
end
|
138
|
+
|
130
139
|
# Wraps the given string in terminal escapes
|
131
140
|
# causing it to have the given color.
|
132
141
|
# If terminal esapes aren't supported on this platform,
|
@@ -300,7 +309,7 @@ END
|
|
300
309
|
'Output style. Can be nested (default), compact, compressed, or expanded.') do |name|
|
301
310
|
@options[:for_engine][:style] = name.to_sym
|
302
311
|
end
|
303
|
-
opts.on('-q', '--quiet', 'Silence warnings during compilation.') do
|
312
|
+
opts.on('-q', '--quiet', 'Silence warnings and status messages during compilation.') do
|
304
313
|
@options[:for_engine][:quiet] = true
|
305
314
|
end
|
306
315
|
opts.on('-g', '--debug-info',
|
data/lib/haml/html.rb
CHANGED
@@ -103,13 +103,6 @@ require 'hpricot'
|
|
103
103
|
# @private
|
104
104
|
HAML_TAGS = %w[haml:block haml:loud haml:silent]
|
105
105
|
|
106
|
-
Hpricot::ElementContent.keys.each do |k|
|
107
|
-
HAML_TAGS.each do |el|
|
108
|
-
val = Hpricot::ElementContent[k]
|
109
|
-
val[el.hash] = true if val.is_a?(Hash)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
106
|
HAML_TAGS.each do |t|
|
114
107
|
Hpricot::ElementContent[t] = {}
|
115
108
|
Hpricot::ElementContent.keys.each do |key|
|
@@ -117,6 +110,13 @@ HAML_TAGS.each do |t|
|
|
117
110
|
end
|
118
111
|
end
|
119
112
|
|
113
|
+
Hpricot::ElementContent.keys.each do |k|
|
114
|
+
HAML_TAGS.each do |el|
|
115
|
+
val = Hpricot::ElementContent[k]
|
116
|
+
val[el.hash] = true if val.is_a?(Hash)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
120
|
module Haml
|
121
121
|
# Converts HTML documents into Haml templates.
|
122
122
|
# Depends on [Hpricot](http://github.com/whymirror/hpricot) for HTML parsing.
|
data/lib/haml/util.rb
CHANGED
@@ -17,6 +17,11 @@ module Haml
|
|
17
17
|
# @api public
|
18
18
|
RUBY_VERSION = ::RUBY_VERSION.split(".").map {|s| s.to_i}
|
19
19
|
|
20
|
+
# The Ruby engine we're running under. Defaults to `"ruby"`
|
21
|
+
# if the top-level constant is undefined.
|
22
|
+
# @api public
|
23
|
+
RUBY_ENGINE = defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby"
|
24
|
+
|
20
25
|
# Returns the path of a file relative to the Haml root directory.
|
21
26
|
#
|
22
27
|
# @param file [String] The filename relative to the Haml root
|
@@ -415,13 +420,25 @@ module Haml
|
|
415
420
|
RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i
|
416
421
|
end
|
417
422
|
|
423
|
+
# Whether or not this is running on IronRuby.
|
424
|
+
#
|
425
|
+
# @return [Boolean]
|
426
|
+
def ironruby?
|
427
|
+
RUBY_ENGINE == "ironruby"
|
428
|
+
end
|
429
|
+
|
418
430
|
## Cross-Ruby-Version Compatibility
|
419
431
|
|
420
432
|
# Whether or not this is running under Ruby 1.8 or lower.
|
421
433
|
#
|
434
|
+
# Note that IronRuby counts as Ruby 1.8,
|
435
|
+
# because it doesn't support the Ruby 1.9 encoding API.
|
436
|
+
#
|
422
437
|
# @return [Boolean]
|
423
438
|
def ruby1_8?
|
424
|
-
|
439
|
+
# IronRuby says its version is 1.9, but doesn't support any of the encoding APIs.
|
440
|
+
# We have to fall back to 1.8 behavior.
|
441
|
+
ironruby? || (Haml::Util::RUBY_VERSION[0] == 1 && Haml::Util::RUBY_VERSION[1] < 9)
|
425
442
|
end
|
426
443
|
|
427
444
|
# Whether or not this is running under Ruby 1.8.6 or lower.
|
data/lib/sass/scss/parser.rb
CHANGED
@@ -98,8 +98,8 @@ module Sass
|
|
98
98
|
node << comment
|
99
99
|
end
|
100
100
|
|
101
|
-
DIRECTIVES = Set[:mixin, :include, :debug, :warn, :for, :while, :if, :
|
102
|
-
:media, :charset]
|
101
|
+
DIRECTIVES = Set[:mixin, :include, :debug, :warn, :for, :while, :if, :else,
|
102
|
+
:extend, :import, :media, :charset]
|
103
103
|
|
104
104
|
def directive
|
105
105
|
return unless tok(/@/)
|
@@ -180,12 +180,14 @@ module Sass
|
|
180
180
|
ss
|
181
181
|
node = block(node(Sass::Tree::IfNode.new(expr)), :directive)
|
182
182
|
pos = @scanner.pos
|
183
|
+
line = @line
|
183
184
|
ss
|
184
185
|
|
185
186
|
else_block(node) ||
|
186
187
|
begin
|
187
188
|
# Backtrack in case there are any comments we want to parse
|
188
189
|
@scanner.pos = pos
|
190
|
+
@line = line
|
189
191
|
node
|
190
192
|
end
|
191
193
|
end
|
@@ -198,16 +200,23 @@ module Sass
|
|
198
200
|
:directive)
|
199
201
|
node.add_else(else_node)
|
200
202
|
pos = @scanner.pos
|
203
|
+
line = @line
|
201
204
|
ss
|
202
205
|
|
203
206
|
else_block(node) ||
|
204
207
|
begin
|
205
208
|
# Backtrack in case there are any comments we want to parse
|
206
209
|
@scanner.pos = pos
|
210
|
+
@line = line
|
207
211
|
node
|
208
212
|
end
|
209
213
|
end
|
210
214
|
|
215
|
+
def else_directive
|
216
|
+
raise Sass::SyntaxError.new(
|
217
|
+
"Invalid CSS: @else must come after @if", :line => @line)
|
218
|
+
end
|
219
|
+
|
211
220
|
def extend_directive
|
212
221
|
node(Sass::Tree::ExtendNode.new(expr!(:selector)))
|
213
222
|
end
|
@@ -421,6 +421,20 @@ HAML
|
|
421
421
|
<tr></tr>
|
422
422
|
<% end %>
|
423
423
|
</table>
|
424
|
+
ERB
|
425
|
+
end
|
426
|
+
|
427
|
+
def test_silent_inside_block_inside_tag
|
428
|
+
assert_equal(<<HAML.rstrip, render_erb(<<ERB))
|
429
|
+
%table
|
430
|
+
- foo.each do
|
431
|
+
- haml_puts "foo"
|
432
|
+
HAML
|
433
|
+
<table>
|
434
|
+
<% foo.each do %>
|
435
|
+
<% haml_puts "foo" %>
|
436
|
+
<% end %>
|
437
|
+
</table>
|
424
438
|
ERB
|
425
439
|
end
|
426
440
|
end
|
data/test/sass/scss/scss_test.rb
CHANGED
@@ -1023,6 +1023,14 @@ MESSAGE
|
|
1023
1023
|
SCSS
|
1024
1024
|
end
|
1025
1025
|
|
1026
|
+
def test_no_lonely_else
|
1027
|
+
assert_raise_message(Sass::SyntaxError, <<MESSAGE.rstrip) {render <<SCSS}
|
1028
|
+
Invalid CSS: @else must come after @if
|
1029
|
+
MESSAGE
|
1030
|
+
@else {foo: bar}
|
1031
|
+
SCSS
|
1032
|
+
end
|
1033
|
+
|
1026
1034
|
# Regression
|
1027
1035
|
|
1028
1036
|
def test_weird_added_space
|
@@ -1083,6 +1091,12 @@ b {
|
|
1083
1091
|
}
|
1084
1092
|
}
|
1085
1093
|
SCSS
|
1094
|
+
end
|
1086
1095
|
|
1096
|
+
def test_if_error_line
|
1097
|
+
assert_raise_line(2) {render(<<SCSS)}
|
1098
|
+
@if true {foo: bar}
|
1099
|
+
}
|
1100
|
+
SCSS
|
1087
1101
|
end
|
1088
1102
|
end
|
data/test/test_helper.rb
CHANGED
@@ -95,4 +95,12 @@ class Test::Unit::TestCase
|
|
95
95
|
else
|
96
96
|
flunk "Expected exception #{klass}, none raised"
|
97
97
|
end
|
98
|
+
|
99
|
+
def assert_raise_line(line)
|
100
|
+
yield
|
101
|
+
rescue Sass::SyntaxError => e
|
102
|
+
assert_equal(line, e.sass_line)
|
103
|
+
else
|
104
|
+
flunk "Expected exception on line #{line}, none raised"
|
105
|
+
end
|
98
106
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 55
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 3.0.
|
9
|
+
- 24
|
10
|
+
version: 3.0.24
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nathan Weizenbaum
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-
|
20
|
+
date: 2010-11-15 00:00:00 -08:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|