[ruby/erb] Fix line numbers after multi-line <%#
(https://github.com/ruby/erb/pull/42) https://github.com/ruby/erb/commit/526885923e
This commit is contained in:
parent
b5726892d0
commit
129d208f9a
@ -384,7 +384,7 @@ class ERB::Compiler # :nodoc:
|
||||
when '<%='
|
||||
add_insert_cmd(out, content)
|
||||
when '<%#'
|
||||
# commented out
|
||||
out.push("\n" * content.count("\n")) # only adjust lineno
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -713,6 +713,18 @@ EOS
|
||||
erb = Marshal.load(Marshal.dump(erb))
|
||||
assert_raise(ArgumentError) {erb.result}
|
||||
end
|
||||
|
||||
def test_multi_line_comment_lineno
|
||||
erb = ERB.new(<<~EOS)
|
||||
<%= __LINE__ %>
|
||||
<%#
|
||||
%><%= __LINE__ %>
|
||||
EOS
|
||||
assert_equal <<~EOS, erb.result
|
||||
1
|
||||
3
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
class TestERBCoreWOStrScan < TestERBCore
|
||||
|
Loading…
x
Reference in New Issue
Block a user