pug - How to return a / respond with (java)script from express.js using JADE -
i'd respond ajax calls on express.js application javascript scripts evaluated in client. how handle jade template construct these scripts dynamically?
thx alot. markus
in app:
app.get('/demo.js', function(req, res) { res.set('content-type', 'text/javascript'); res.render('script', { value : math.random() }); }); in template (script.jade):
|var somevar = #{value}; test:
$ http localhost:3012/demo.js ... http/1.1 200 ok connection: keep-alive content-length: 33 content-type: text/javascript date: fri, 10 may 2013 14:30:54 gmt x-powered-by: express var somevar = 0.9364965052809566;
Comments
Post a Comment