Skip to content

Commit

Permalink
fix(html): do not add extra indent for js template in script (#5527)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatyang committed Nov 23, 2018
1 parent cdac955 commit 228a8b0
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
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>

0 comments on commit 228a8b0

Please sign in to comment.