I want to put the below html code in my javascript function. I don\'t want to put it all next to each other. Is it possible to the code in the same way as how it is in html? Cod
Really old question, but I don't find this syntax a lot, so I'll just leave this here, as to me it is the most readable.
var html = '' +
' ';
With a simple shell command to generate this from an html file:
cat myfile.html | sed "s/'/\\'/g" | sed "$ ! s/^.*$/'\0' +/g" | sed "$ s/^.*$/'\0';/"
Update: With ES6, simply use backticks:
const html = `
`;