Conversation
|
This only works if it's the first attribute in the list, and doesn't work for more complex JavaScript expressions. It would be nice to adapt it to work more reliably. |
Yeah, since the dots might be part of a JavaScript expression (e.g. |
7708e23 to
59f392c
Compare
|
Just implemented that. All tests pass. |
test/cases/attrs-spread.pug
Outdated
There was a problem hiding this comment.
Just a question: what is the foo? Why couldn't one just do (...foo)?
There was a problem hiding this comment.
My thinking was that it could mean you can namespace things: e.g.
div(...data=myDataAttributes)
compiled with:
{myDataAttributes: {foo: 'foo-val', bar: 'bar-val'}}results in:
<div data-foo="foo-val" data-bar="bar-val"></div>Probably this is the wrong syntax for that though. I think I would prefer to support something like:
div(data=...myDataAttributes)
or
div(data...=myDataAttributes)
as I think that reads better/more clearly. Probably best to remove support for having a "value" for spread attributes. If we make sure it's a syntax-error for now, we can always add it in later.
|
Awesome. One last thing before we merge this: We should define a new token-type of |
|
So basically there are two classes of spread attributes:
I'll use |
|
Sounds good. I'm inclined to only implement |
|
I'm labeling this as a breaking change because we currently allow attributes at the start to be like |
|
Yep, sounds about right. |
Fixes column tracking of quoted attribute keys with commas. Fixes `a(attr, 'weird=')`.
ebe6467 to
6d406e4
Compare
|
Pushed a few commits that 1. added an unescaped version ( |
These currently already lex without any problems. I’d like to use these to replace
&attributesand provide proper escaping in the process