Skip to content

Engine: Herb builds invalid ruby when HEREDOC is present #1245

Description

@joelhawksley

Given the template file:

<%
  text = <<~TEXT
    Hello, world!
  TEXT
%>

When compiling the template with actionview_precompiler:

...action_view/template.rb:502:in 'Module#module_eval': --> ../template.html.erb

unexpected '<', ignoring it
unexpected constant, expecting end-of-input
unexpected write target
unterminated string meets end of file

> 1  <%
> 5  %>

.../template.html.erb:1: syntax errors found (SyntaxError)
  -1 | # frozen_string_literal: true
> 0 |           def _template ...
    |           ^~~ expected an `end` to close the `def` statement
> 1 | ... TEXT
    |     ^~~~ unterminated heredoc; can't find string "TEXT" anywhere before EOF
  2 |     Hello, world!
  3 |   TEXT 
  4 | @output_buffer
> 5 |           end
    |              ^ unexpected end-of-input, assuming it is closing the parent top level context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingengine

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions