I have this code in my index.pug
file
doctype html
html
head
title= title
body
script(src=`${source}`)
script.
for (var event of events){
VClient.Event.subscribe(event, createDiv);
}
And here is how I pass the variables from Express to pug.
var express = require('express');
var app = express();
app.set('view engine', 'pug')
app.get('/', function(req, res){
var id = req.query.id || 23717;
var source = `https://some.source.url/${id}.js`;
res.render('index',
{title: 'Preview Embed', source: source, events:["AD_START","AD_COMPLETE"]});
});
app.listen(5000);
Both title
and source
make it to the pug file. But not the events
:
Uncaught ReferenceError: events is not defined
How do I correctly pass the variable inside the script.
block?