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

master
Ika 2018-11-23 15:20:30 +08:00 committed by GitHub
parent cdac9552ef
commit 228a8b0782
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 1 deletions

View File

@ -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)
])
]);

View File

@ -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 {

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<script>
function foo() {
return `
<div>
<p>Text</p>
</div>
`;
}
</script>
</body>
</html>