Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow string interpolation in attribute names #7

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nbelzer
Copy link

@nbelzer nbelzer commented Apr 25, 2023

Resolves #5

This is a partial solution, and I'm hoping to find some guidance to complete it.

I ran into a similar issue to #5 with the following error:

Don't know how to process attribute: "data----view-component-identifier----<%=UI::Inputs::NewAddressSelector::Component.identifier %>-outlet=\"<%= UI::Inputs::NewAddressSelector::Component.selector %>\""

With my level of understanding of regexp it seems like adjusting the ATTR_NAME regexp to allow for erb tags is not possible, as it means removing the characters <%=> from the negated set, however, this would allow full html tags to be included in the match. For example it would then match <span foo="bar" out of <span foo="bar"></span> (while we only want foo="bar").

The approach I found to work is the one outlined in this PR. The solution itself comes down to deferring the substitution of the erb tags such that we don't have to deal with them while matching with the ATTR_NAME regexp. I'm not very happy with this solution because it now requires many lines to call gsub, so I hope to improve it before merging.

Additionally the attribute names produced by this are not valid as they look like this:

data-erb-data-<erb silent erb-code=\" identifier \"></erb>=\"bar\"

@nbelzer nbelzer self-assigned this Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supporting string interpolation in attribute names
1 participant