Skip to content

Instantly share code, notes, and snippets.

@UnidentifiedContributor
Created December 20, 2014 11:11
Show Gist options
  • Save UnidentifiedContributor/f56455061ee26f21fb29 to your computer and use it in GitHub Desktop.
Save UnidentifiedContributor/f56455061ee26f21fb29 to your computer and use it in GitHub Desktop.
Output JSON to EJS
<html></html><script>var somevar = <%- somevar %></script><body></body></html>
var express = require('express')
var app = express()
var somevar = {
"this" : "that"
, "what" : "lol"
}
app.set('view engine', 'ejs');
app.get('/', function(req, res, next) {
res.render('index', { somevar : JSON.stringify(somevar) });
})
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment