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

fix(html): do not add extra indent for js template in script #5527

Merged
merged 3 commits into from Nov 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/language-html/printer-html.js
Expand Up @@ -68,7 +68,7 @@ function embed(path, print, textToDoc, options) {
concat([
breakParent,
printOpeningTagPrefix(node, options),
markAsRoot(stripTrailingHardline(textToDoc(value, { parser }))),
stripTrailingHardline(textToDoc(value, { parser })),
printClosingTagSuffix(node, options)
])
]);
Expand Down
36 changes: 36 additions & 0 deletions tests/html_js/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -127,6 +127,42 @@ exports[`something-else.html - html-verify 1`] = `

`;

exports[`template-literal.html - html-verify 1`] = `
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<script>
function foo() {
return \`
<div>
<p>Text</p>
</div>
\`;
}
</script>
</body>
</html>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<!DOCTYPE html>
<html lang="en">
<head> </head>
<body>
<script>
function foo() {
return \`
<div>
<p>Text</p>
</div>
\`;
}
</script>
</body>
</html>

`;

exports[`typescript.html - html-verify 1`] = `
<script type="application/x-typescript">
class Student {
Expand Down
16 changes: 16 additions & 0 deletions tests/html_js/template-literal.html
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<script>
function foo() {
return `
<div>
<p>Text</p>
</div>
`;
}
</script>
</body>
</html>