From: takashikkbn@... Date: 2021-05-04T02:12:04+00:00 Subject: [ruby-core:103709] [Ruby master Bug#17846] Percent mode changes the output from ERB beyond what is documented Issue #17846 has been updated by k0kubun (Takashi Kokubun). Status changed from Feedback to Rejected So the trick is: ```rb $ erb -x repro.erb #coding:UTF-8 _erbout = +''; # ; _erbout.<< "x\n".freeze ; _erbout.<< "y\n".freeze ; _erbout ``` ```rb $ erb -x -P repro.erb #coding:UTF-8 _erbout = +''; # ; _erbout.<< "x\ny\n".freeze ; _erbout ``` At glance, the generated code seems broken. However, @xtkoba made the point; `<%#` is a special token of ERB that allows a Ruby comment, whereas `<% #` is a Ruby expression with a comment. I think writing a comment in the middle of `<% %>` is currently not supported. For your case, you should just use `<%#` instead of `<% #`. ---------------------------------------- Bug #17846: Percent mode changes the output from ERB beyond what is documented https://bugs.ruby-lang.org/issues/17846#change-91802 * Author: graywolf (Gray Wolf) * Status: Rejected * Priority: Normal * ruby -v: ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-linux-musl] * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- ``` / # cat repro.erb <% # %>x y / # erb repro.erb y / # erb -P repro.erb / # ``` Based on documentation of -P (disabling percent mode), this change in behavior is unexpected. -- https://bugs.ruby-lang.org/ Unsubscribe: