At a glance, the generated code seems broken. However, @xtkoba (Tee KOBAYASHI) made the point; <%# is a special token of ERB that allows a Ruby comment, whereas <% # is a Ruby expression with a comment. While it sounds strange that it's impacted by -P, whether -P or not, writing a comment in the middle of <% %> is currently not supported. For your case, you should just use <%# instead of <% #.
[..] writing a comment in the middle of <% %> is currently not supported.
I don't really have an issue with this resolution, however, is it documented
somewhere? I cannot find this mentioned anywhere in the documentation nor the
source code.