-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Handlebars: fix formatting of attributes #10145
Conversation
2a393a6
to
4f3ac2a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left one small comment about n.chars
that might be transformed into text
. Sounds like a great improvement overall.
Do you think we should use src/language-html/syntax-attribute.js
functions to format handlebars attributes in the future?
@@ -204,8 +254,6 @@ function print(path, options, print) { | |||
const [lead] = n.chars.match(leadingWhitespacesRE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [lead] = n.chars.match(leadingWhitespacesRE); | |
const [lead] = text.match(leadingWhitespacesRE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also on lines 295:299 (can't suggest there)
@@ -204,8 +254,6 @@ function print(path, options, print) { | |||
const [lead] = n.chars.match(leadingWhitespacesRE); | |||
const [tail] = n.chars.match(trailingWhitespacesRE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [tail] = n.chars.match(trailingWhitespacesRE); | |
const [tail] = text.match(trailingWhitespacesRE); |
return [quote, stringLiteral.replace(regex, `\\${quote}`), quote]; | ||
} | ||
|
||
function chooseEnclosingQuote(options, stringLiteral) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -0,0 +1,25 @@ | |||
#### Fix formatting of attributes (#10145 by @thorn0) | |||
|
|||
- fix escaping of `{{` in attributes and text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch, I had this refactor / fix on a branch too
What can be reused should definitely be reused, but we need to figure out a way to share that code between the two printers. Currently |
@dcyriller Just realized that I was wrong here:
Only the parsers are extracted to separate bundles. The printers all go in one bundle, so it's okay to |
Description
This PR
{{
in attributes and text'
and"
for attributes with interpolations[object Object]
printed inclass
class
, like in HTML in the current stable version (before Smarter formatting of HTML class attribute #7865)Closes #8648
Closes #8667
cc @dcyriller @kangax
Checklist
changelog_unreleased/*/XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨