haml 3.1.1 → 3.1.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/VERSION +1 -1
- data/lib/haml/compiler.rb +1 -1
- data/lib/haml/exec.rb +1 -1
- data/lib/haml/helpers.rb +5 -3
- data/lib/haml/helpers/action_view_mods.rb +14 -2
- data/lib/haml/parser.rb +1 -1
- data/test/haml/engine_test.rb +14 -0
- data/test/haml/helper_test.rb +4 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.2
|
data/lib/haml/compiler.rb
CHANGED
@@ -379,7 +379,7 @@ END
|
|
379
379
|
value = Haml::Helpers.preserve(escaped)
|
380
380
|
if escape_attrs
|
381
381
|
# We want to decide whether or not to escape quotes
|
382
|
-
value.gsub
|
382
|
+
value = value.gsub('"', '"')
|
383
383
|
this_attr_wrapper = attr_wrapper
|
384
384
|
if value.include? attr_wrapper
|
385
385
|
if value.include? other_quote_char
|
data/lib/haml/exec.rb
CHANGED
data/lib/haml/helpers.rb
CHANGED
@@ -107,7 +107,9 @@ MESSAGE
|
|
107
107
|
# @yield The block within which to escape newlines
|
108
108
|
def find_and_preserve(input = nil, tags = haml_buffer.options[:preserve], &block)
|
109
109
|
return find_and_preserve(capture_haml(&block), input || tags) if block
|
110
|
-
|
110
|
+
re = /<(#{tags.map(&Regexp.method(:escape)).join('|')})([^>]*)>(.*?)(<\/\1>)/im
|
111
|
+
input.to_s.gsub(re) do |s|
|
112
|
+
s =~ re # Can't rely on $1, etc. existing since Rails' SafeBuffer#gsub is incompatible
|
111
113
|
"<#{$1}#{$2}>#{preserve($3)}</#{$1}>"
|
112
114
|
end
|
113
115
|
end
|
@@ -170,10 +172,10 @@ MESSAGE
|
|
170
172
|
result = capture_haml(i, &block)
|
171
173
|
|
172
174
|
if result.count("\n") > 1
|
173
|
-
result.gsub
|
175
|
+
result = result.gsub("\n", "\n ")
|
174
176
|
result = "\n #{result.strip}\n"
|
175
177
|
else
|
176
|
-
result.strip
|
178
|
+
result = result.strip
|
177
179
|
end
|
178
180
|
|
179
181
|
"<li>#{result}</li>"
|
@@ -51,7 +51,10 @@ module ActionView
|
|
51
51
|
# We've got to do the same thing for compatibility.
|
52
52
|
|
53
53
|
if is_haml? && block_is_haml?(block)
|
54
|
-
|
54
|
+
value = nil
|
55
|
+
buffer = capture_haml(*args) { value = yield(*args) }
|
56
|
+
return buffer unless buffer.empty?
|
57
|
+
return value if value.is_a?(String)
|
55
58
|
else
|
56
59
|
capture_without_haml(*args, &block)
|
57
60
|
end
|
@@ -85,7 +88,16 @@ module ActionView
|
|
85
88
|
module CaptureHelper
|
86
89
|
def capture_with_haml(*args, &block)
|
87
90
|
if Haml::Helpers.block_is_haml?(block)
|
88
|
-
|
91
|
+
value = nil
|
92
|
+
buffer = capture_haml(*args) { value = yield(*args) }
|
93
|
+
str =
|
94
|
+
if !buffer.empty?
|
95
|
+
buffer
|
96
|
+
elsif value.is_a?(String)
|
97
|
+
value
|
98
|
+
else
|
99
|
+
''
|
100
|
+
end
|
89
101
|
return ActionView::NonConcattingString.new(str) if defined?(ActionView::NonConcattingString)
|
90
102
|
return str
|
91
103
|
else
|
data/lib/haml/parser.rb
CHANGED
@@ -146,7 +146,7 @@ END
|
|
146
146
|
|
147
147
|
@tab_up = nil
|
148
148
|
process_line(@line.text, @line.index) unless @line.text.empty? || @haml_comment
|
149
|
-
if block_opened? || @tab_up
|
149
|
+
if @parent.type != :haml_comment && (block_opened? || @tab_up)
|
150
150
|
@template_tabs += 1
|
151
151
|
@parent = @parent.children.last
|
152
152
|
end
|
data/test/haml/engine_test.rb
CHANGED
@@ -382,6 +382,20 @@ SOURCE
|
|
382
382
|
assert_equal("<p foo='bar'></p>\n", render('%p{:foo => "bar"}', :attr_wrapper => nil))
|
383
383
|
end
|
384
384
|
|
385
|
+
def test_comment_with_crazy_nesting
|
386
|
+
assert_equal(<<HTML, render(<<HAML))
|
387
|
+
foo
|
388
|
+
bar
|
389
|
+
HTML
|
390
|
+
foo
|
391
|
+
-#
|
392
|
+
ul
|
393
|
+
%li{
|
394
|
+
foo
|
395
|
+
bar
|
396
|
+
HAML
|
397
|
+
end
|
398
|
+
|
385
399
|
# Regression tests
|
386
400
|
|
387
401
|
def test_whitespace_nuke_with_both_newlines
|
data/test/haml/helper_test.rb
CHANGED
@@ -357,6 +357,10 @@ HAML
|
|
357
357
|
assert_equal("1\n\n2\n\n3\n\n", render("- trc([1, 2, 3]) do |i|\n = i.inspect"))
|
358
358
|
end
|
359
359
|
|
360
|
+
def test_capture_with_string_block
|
361
|
+
assert_equal("foo\n", render("= capture { 'foo' }", :action_view))
|
362
|
+
end
|
363
|
+
|
360
364
|
def test_find_and_preserve_with_block
|
361
365
|
assert_equal("<pre>Foo
Bar</pre>\nFoo\nBar\n",
|
362
366
|
render("= find_and_preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
|
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: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 3.1.
|
9
|
+
- 2
|
10
|
+
version: 3.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nathan Weizenbaum
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-06-07 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|