summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-03 18:11:47 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-03 18:11:47 +0000
commit887dced42e51e79734c75e77bdfb69c56493e6e3 (patch)
tree760588e555437d6e106f2571cc817b673b4ffe94 /lib
parentdc96b227d5df77f80098dc7172c91789673fa4d1 (diff)
merge revision(s) 61497: [Backport #14243]
erb.rb: preserve the behavior for invalid syntax comment. Fix regression at r58948. I even don't want to deprecate it because deprecation needs to lex all embedded Ruby script using Ripper and it would be slow. So Let me just keep this behavior of Ruby 2.4. No change is the best compatibility. This commit stopped using String#-@ because it's harmful for "ambiguous first argument" warning if we really want to maintain this behavior. [Bug #14243] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@61581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/erb.rb17
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/erb.rb b/lib/erb.rb
index c616178507..062fd496b9 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -291,7 +291,7 @@ class ERB
# <i>Generates</i>:
#
# #coding:UTF-8
- # _erbout=+''; _erbout.<<(-"Got "); _erbout.<<(( obj ).to_s); _erbout.<<(-"!\n"); _erbout
+ # _erbout=+''; _erbout.<< "Got ".freeze; _erbout.<<(( obj ).to_s); _erbout.<< "!\n".freeze; _erbout
#
# By default the output is sent to the print method. For example:
#
@@ -302,7 +302,7 @@ class ERB
# <i>Generates</i>:
#
# #coding:UTF-8
- # print(-"Got "); print(( obj ).to_s); print(-"!\n")
+ # print "Got ".freeze; print(( obj ).to_s); print "!\n".freeze
#
# == Evaluation
#
@@ -576,17 +576,8 @@ class ERB
end
end
- def content_dump(s) # :nodoc:
- n = s.count("\n")
- if n > 0
- s.dump << "\n" * n
- else
- s.dump
- end
- end
-
def add_put_cmd(out, content)
- out.push("#{@put_cmd}(-#{content_dump(content)})")
+ out.push("#{@put_cmd} #{content.dump}.freeze#{"\n" * content.count("\n")}")
end
def add_insert_cmd(out, content)
@@ -668,7 +659,7 @@ class ERB
when '<%='
add_insert_cmd(out, content)
when '<%#'
- # out.push("# #{content_dump(content)}")
+ # commented out
end
end