Skip to content

Conversation

@marcoroth
Copy link
Owner

@marcoroth marcoroth commented Nov 13, 2025

This pull request fixes the parser to correctly handle ERB control flow tags when parsing HTML attributes.

Previously, control flow tags like <% if %>, <% end %>, and <%# comment %> were incorrectly included as part of attribute names and values. Now, only ERB output tags (<%=, <%==) can be part of attribute names, while control flow tags properly terminate attribute name and attribute value parsing.

This enables patterns like this, where there is no space between the closing %> and the attribute name:

<dialog data-controller="dialog" <% if condition %>data-turbo-permanent<% end %>></dialog>
<div <% if admin? %>data-admin data-role="admin"<% end %>></div>

Resolves #872

)) {
if (token_is(parser, TOKEN_ERB_START)) {
const char* tag = parser->current_token->value;
bool is_output_tag = (tag[2] == '=');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: What if the tag length is less than 3?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Remove the braces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect MissingERBEndTagError

3 participants