Jack Wang Jack Wang - 8 months ago 119
Jade Question

how to render JavaScript using pug/jade

For example, I pass a

variable to this pug file, and I want to run some js code after dom has loaded.

document.addEventListener("DOMContentLoaded", function(event) {
console.log(#{user.name});//log the user's name

Is it possible to do so?


First, you're trying to use a string interpolation #{user.name} outside of a string. Use !{user.name} instead for unescaped code interpolation.