So what I want is to put some multiline HTML into a Pug file and can't find anywhere how to do this.
Example:
html
head
body
<div><a href="lala"> blabla </a></div>
p hihuhohoo
So what I want is to put some multiline HTML into a Pug file and can't find anywhere how to do this.
Example:
html
head
body
<div><a href="lala"> blabla </a></div>
p hihuhohoo
Pug text can include HTML. Just force it as text, and it should parse:
html
head
body
| <div><a href="lala"> blabla </a></div>
p hihuhohoo
Also, you were using backslashes, not forward slashes, to close elements.
| !{paramName}
–
Pouched This is a tested example with passing variables with raw html
to the pug file:
yourSourceFile.js
const p1 = 'This server uses a <a href="https://pugjs.org/api/getting-started.html" target="_blank">pug template</a> for the html output'
res.render('yourTemplateFile', { title: 'Hey', p1 })
yourTemplateFile.pug
html
head
title= title
body
p
| !{p1}
I was only able to do this by encoding < and >
div
| <script src="https://mydomain.io/script.js"></script>
© 2022 - 2024 — McMap. All rights reserved.