1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

[Haml] Fix a bunch of 1.9.1 compatibility issues.

There's still one test failure that only appears for me when I run all the tests
and doesn't have a meaningful backtrace.
This commit is contained in:
Nathan Weizenbaum 2009-02-07 02:33:58 -08:00
parent 23848a2ce4
commit f7a05f7e7d
12 changed files with 23 additions and 34 deletions

View file

@ -42,8 +42,8 @@ module Haml
# SyntaxErrors have weird line reporting
# when there's trailing whitespace,
# which there is for Haml documents.
return exception.message.scan(/:(\d+)/)[0] if exception.is_a?(::SyntaxError)
exception.backtrace[0].scan(/:(\d+)/)[0]
return exception.message.scan(/:(\d+)/).first.first if exception.is_a?(::SyntaxError)
exception.backtrace[0].scan(/:(\d+)/).first.first
end
private

View file

@ -225,7 +225,8 @@ END
def compile(precompiler, text)
return if precompiler.options[:suppress_eval]
src = ::ERB.new(text).src.sub(/^_erbout = '';/, "").gsub("\n", ';')
src = ::ERB.new(text).src.sub(/^#coding:.*?\n/, '').
sub(/^_erbout = '';/, "").gsub("\n", ';')
precompiler.send(:push_silent, src)
end
end

View file

@ -269,10 +269,9 @@ module Haml
min_tabs = min_tabs > tabs ? tabs : min_tabs
end
result = captured.map do |line|
captured.map do |line|
line[min_tabs..-1]
end
result.to_s
end.join
end
end

View file

@ -79,7 +79,7 @@ module Haml
class ::Hpricot::Doc
def to_haml(tabs = 0)
output = ''
children.each { |child| output += child.to_haml(0) }
children.each { |child| output += child.to_haml(0) } if children
output
end
end
@ -148,13 +148,9 @@ module Haml
output += haml_attributes if attributes.length > 0
end
output += "\n"
self.children.each do |child|
output += child.to_haml(tabs + 1)
(self.children || []).inject(output + "\n") do |output, child|
output + child.to_haml(tabs + 1)
end
output
end
private

View file

@ -492,7 +492,7 @@ HAML
def test_compile_error
render("a\nb\n- fee)\nc")
rescue Exception => e
assert_match(/^compile error\n\(test_compile_error\):3: syntax error/i, e.message)
assert_match(/\(test_compile_error\):3: syntax error/i, e.message)
else
assert(false,
'"a\nb\n- fee)\nc" doesn\'t produce an exception!')

View file

@ -52,11 +52,6 @@ This
</ul>
<div class='res'>178</div>
<ul>
<li>Foo</li>
<li>Bar</li>
<li>BAZ!</li>
</ul>
Text!
Hello, World!
How are you doing today?

View file

@ -31,7 +31,7 @@
<li>f</li>
</ul>
<div class='of_divs_with_underscore' id='combo'>with this text</div>
hello
foo
<div class='footer'>
<strong class='shout'>
This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid.

View file

@ -36,7 +36,10 @@
</div>
<div class='foo'>
13
<textarea>&#x000A;a</textarea><textarea>&#x000A;b</textarea><textarea>&#x000A;c</textarea>
<textarea>
a
</textarea>
<textarea>&#x000A;a</textarea>
</div>
<div id='whitespace_test'>
<div class='text_area_test_area'>

View file

@ -23,7 +23,7 @@
"multiline " +
"tags! " +
"A pipe (|) even!" %>
<%= [1, 2, 3].collect { |n| "PipesIgnored|" } %>
<%= [1, 2, 3].collect { |n| "PipesIgnored|" }.join %>
<%= [1, 2, 3].collect { |n|
n.to_s
}.join("|") %>
@ -41,8 +41,8 @@
<li><%= a %>
<% end %>
<div class='of_divs_with_underscore' id='combo'><%= @should_eval = "with this text" %></div>
<%= [ 104, 101, 108, 108, 111 ].map do |byte|
byte.chr
<%= "foo".each_line do |line|
nil
end %>
<div class='footer'>
<strong class='shout'>

View file

@ -53,11 +53,6 @@
.res= res
:markdown
* Foo
* Bar
* BAZ!
= "Text!"
- var = "Hello"

View file

@ -19,7 +19,7 @@
"multiline " + |
"tags! " + |
"A pipe (|) even!" |
= [1, 2, 3].collect { |n| "PipesIgnored|" }
= [1, 2, 3].collect { |n| "PipesIgnored|" }.join
= [1, 2, 3].collect { |n| |
n.to_s |
}.join("|") |
@ -36,7 +36,7 @@
- ('a'..'f').each do |a|
%li= a
#combo.of_divs_with_underscore= @should_eval = "with this text"
= [ 104, 101, 108, 108, 111 ].map do |byte|
- byte.chr
= "foo".each_line do |line|
- nil
.footer
%strong.shout= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid. \nSo, I'm just making it *really* long. God, I hope this works"

View file

@ -12,8 +12,8 @@
%p~ "foo\nbar"
.foo
~ 13
~ ['a', 'b', 'c'].map do |a|
- "<textarea>\n#{a}\n</textarea>"
~ "<textarea>\na\n</textarea>".each_line do |l|
- haml_concat l.strip
#whitespace_test
= test_partial "text_area", :value => "Oneline"
= test_partial "text_area", :value => "Two\nlines"