Skip to content

Parsing Error when using no-output erb tags in certain contexts #15

@gravitystorm

Description

@gravitystorm

Thanks for the plugin! I'm trying to get it running on our existing codebase, but I've run into a situation where most of our erb files don't parse. They contain code something similar to:

OSM = {
<% if something %>
  MATOMO: <%= Settings.matomo.to_json %>,
<% end %>
  MAX_REQUEST_AREA: <%= Settings.max_request_area.to_json %>
}

If I understand correctly, both <% %> and <%= %> tags get converted into the same placeholder - effectively {}. However, this leads to the parser error:

OSM = {
{}
  MATOMO: {},
{}
  MAX_REQUEST_AREA: {}
}

I can see that replacing the erb-output tags (e.g. <%= %>) with {} makes sense. But does the same hold true for the non-output tags like <% %>? Would it be better to use a different placeholder (e.g. just a comment with the hash etc) for these tags?

OSM = {
/* zero output placeholder comment */
  MATOMO: {},
/* zero output placeholder comment */
  MAX_REQUEST_AREA: {}
}

Sorry in advance if I'm overlooking anything here!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions