Leslie Leslie - 5 months ago 79
HTML Question

Jade syntax about multiple line string in pre tag

I have Jade code like this:

pre='<!DOCTYPE html>\n<html lang="en">\nfoo bar\n</html>'


and it render like this:

<!DOCTYPE html>
<html lang="en">
foo bar
</html>


How can I achieve something like this:

pre='<!DOCTYPE html>\n'
+'<html lang="en">\n'
+'foo bar\n'
+'</html>'


or like this:

pre="""<!DOCTYPE html>\n"""
"""<html lang="en">\n"""
"""foo bar\n"""
"""</html>"""


Update:
I have tried following code in jade-syntax-docs, it works!

pre
| <!DOCTYPE html>
| <html lang="en">
| foo bar
| </html>


enter image description here

But it not works in my test website. My website is generated by express generator.
It render like this:

enter image description here

and html is this:

enter image description here

If jade version matters, this is
package.json
:

{
"name": "nodejs-crud",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.13.2",
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"express": "~4.13.1",
"jade": "~1.11.0",
"morgan": "~1.6.1",
"serve-favicon": "~2.3.0"
}
}


By the way, I use
bootstrap
.

Answer

You can also do this :

pre
| <!DOCTYPE html>
| foo bar
| </html>
Comments