Content interpolated with bracket syntax will be evaluated for code, the output of which is included in your HTML output.
title follows the basic pattern for evaluating a template local, but the code in between
#{
and}
is evaluated, escaped, and the result buffered into the output of the template being rendered. [Source]
If you need to include raw HTML syntax, use an exclamation point instead of a pound symbol (!{}
instead of #{}
).
index.js
let tag = "<div>You can't escape me!</div>";
res.render("index", {
myTag: tag
});
index.pug
doctype html
html
head
body
!{myTag}
index.pug output
<!DOCTYPE html>
<html>
<head></head>
<body>
<div>You can't escape me!</div>
</body>
</html>