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

special characters in attribute names #212

Open
punund opened this issue Apr 1, 2018 · 4 comments
Open

special characters in attribute names #212

punund opened this issue Apr 1, 2018 · 4 comments

Comments

@punund
Copy link

punund commented Apr 1, 2018

Certain frameworks rely on specifically crafted attributes:

    <button v-on:submit.prevent=foo>

However, blade fails if given

 button(v-on:submit.prevent="foo")

This wouldn't work either:

 button(@attr="foo")
@bminer
Copy link
Owner

bminer commented Apr 2, 2018

Ewww... : and @ are not supported by XHTML in the attribute name as far as I know. I'm not quite sure about HTML5.

I don't really want to support non-standard attribute names in a HTML templating language. That said, it should be as simple as loosening the Blade parser rules.

Which frameworks use these weird attribute names?

@punund
Copy link
Author

punund commented Apr 2, 2018

This syntax is from vue.js, and I don't think they care about XHTML. As per the HTML5 specs, almost anything is valid in HTML attribute names:

Attribute names must consist of one or more characters other than controls, U+0020 SPACE, U+0022 ("), U+0027 ('), U+003E (>), U+002F (/), U+003D (=), and noncharacters.

Custom attributes are part of the specs, e.g., "data-" attributes, so it is reasonable to support them in a templating language, as I may legally want to have

    <p data-is.mine="foo">

in a perfectly valid HTML5 document, but blade would fail on the dot. Client-side frameworks all use their own attributes, which are technically invalid, but are stripped before being given to the browser: vue.js uses v-, angular ng-, and sometime they would use '@' or ':' for shortcuts. They won't pass validation, but they are "well-formed" in a sense.

@bminer
Copy link
Owner

bminer commented Apr 10, 2018

Hm, alright. If it's a Vue thing, I suppose the Blade parser should support it. Have you ever tried Riot.js?

@bminer
Copy link
Owner

bminer commented Oct 2, 2018

Just following up. Would you be willing to do a PR for this? It would likely involve updating the PEG.js parser rules. If you're uncomfortable doing so, I don't blame you... there's a small learning curve involved.

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

No branches or pull requests

2 participants