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

Attribute quoting not working in some cases #95

Open
fiddlerwoaroof opened this issue May 19, 2024 · 4 comments
Open

Attribute quoting not working in some cases #95

fiddlerwoaroof opened this issue May 19, 2024 · 4 comments

Comments

@fiddlerwoaroof
Copy link

fiddlerwoaroof commented May 19, 2024

*always-quote* is ignored for some sorts of tags. This causes issues with other tools (such as prettier) that don't like attribute values with slashes.

FORMAT-ST-SNIPS> (let ((spinneret:*always-quote* t))
                   (spinneret:with-html (:link :href "/foo")))
<link href=/foo>
@fiddlerwoaroof
Copy link
Author

Actually, I just realized this is a macro issue: the LET binding isn't active while the with-html macro is being expanded. So, as implemented, *always-quote*, has to be set with SETF before any invocation of with-html

@ruricolist
Copy link
Owner

I looked into reporting this as a bug on Prettier, but it's been a known bug since 2020: angular/angular#36932.

In principle I'd be willing to change the handling of attribute values for better parser compatibility, but I'm hesitant to do it for just one parser.

@fiddlerwoaroof
Copy link
Author

I wonder if there's a way to make always-quote work with a LET binding. I didn't quite follow the macroexpansion, but it's a bit surprising to me that this variable affects macroexpansion rather than being used by the generated code: is there a performance concern?

As far as prettier goes: I understand not wanting to adjust the behavior for a single parse but prettier is the de facto standard tool for reformatting HTML and other languages found in frontend codebases. If there's a single tool to target, I think prettier would be it.

ruricolist added a commit that referenced this issue May 24, 2024
@ruricolist
Copy link
Owner

I've change the default behavior to always quote attributes with slashes. I'm leaving this issue open for the moment to think about how and if always-quote should have a run-time effect.

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

No branches or pull requests

2 participants