fix(javascript): remove unnecessary linebreaks from html templates (#5771)

master
Ika 2019-01-20 11:15:18 +08:00 committed by GitHub
parent 1dea4ef6f2
commit 42f7b6025e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 11 deletions

View File

@ -610,18 +610,8 @@ function printHtmlTemplateLiteral(path, print, textToDoc, parser) {
}
const placeholderIndex = +component;
parts.push(
concat([
"${",
group(
concat([
indent(concat([softline, expressionDocs[placeholderIndex]])),
softline
])
),
"}"
])
concat(["${", group(expressionDocs[placeholderIndex]), "}"])
);
}

View File

@ -59,6 +59,15 @@ html\` <\${Footer} >footer content<// > \`
html\` <div /> \`
function HelloWorld() {
return html\`
<h3>Bar List</h3>
\${bars.map(bar => html\`
<p>\${bar}</p>
\`)}
\`;
}
=====================================output=====================================
import { LitElement, html } from "@polymer/lit-element";
@ -110,5 +119,16 @@ html\`
<div />
\`;
function HelloWorld() {
return html\`
<h3>Bar List</h3>
\${bars.map(
bar => html\`
<p>\${bar}</p>
\`
)}
\`;
}
================================================================================
`;

View File

@ -50,3 +50,12 @@ html`<my-element obj=${obj}></my-element>`;
html` <${Footer} >footer content<// > `
html` <div /> `
function HelloWorld() {
return html`
<h3>Bar List</h3>
${bars.map(bar => html`
<p>${bar}</p>
`)}
`;
}