json-globals

Embed JSON in a page as temporary global data

MIT License

Downloads
705
Stars
7

json-globals

Embed JSON in a page as temporary global data

Example for the server

var JSONGlobals = require("json-globals")

function (req, res) {
    getUser(req, res, function (userRecord) {
        var text = JSONGlobals({ user: userRecord })
        var html = "" // whatever html

        html += "<script>" + text + "</script>"

        res.end(html)
    })
}

Example for the client

var JSONGlobals = require("json-globals/get")

var user = JSONGlobals("user")

Installation

npm install json-globals

Contributors

  • Raynos

MIT Licenced

Package Rankings
Top 5.65% on Npmjs.org
Badges
Extracted from project README
build status dependency status