In es6 template literals, how can one wrap a long template literal to multiline without creating a new line in the string?
For example, if you do this:
If you introduce a line continuation (\
) at the point of the newline in the literal, it won't create a newline on output:
const text = `a very long string that just continues\
and continues and continues`;
console.log(text); // a very long string that just continuesand continues and continues
Similar to Doug's answer this is accepted by my TSLint config and remains untouched by my IntelliJ auto-formatter:
const text = `a very long string that just ${
continues
} and ${continues} and ${continues}`
The solution proposed by @CodingIntrigue is not working for me on node 7. Well, it works if I do not use a line continuation on the first line, it fails otherwise.
This is probably not the best solution, but it works without problems:
(`
border:1px solid blue;
border-radius:10px;
padding: 14px 25px;
text-decoration:none;
display: inline-block;
text-align: center;`).replace(/\n/g,'').trim();