Jack Wang Jack Wang - 1 year ago 191
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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download