Skip to content

bevacqua/jsn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsn is an open-source Node to JavaScript variable parser.

What does JSN do?

jsn will take variables you pass as a context, and parse the source code to produce valid JavaScript.

Sample .jsn file:

var thatMuch = '@how.awesome';
alert(thatMuch);

You will need to install jsn, you can do that directly from npm

npm install jsn

In your Node.JS code, you can parse these variables by accessing the jsn compiler.

var jsn = require('jsn');

jsn.parse(source, { how: { awesome: 'well, very much, tee-hee!' } }, function(err, js){
    if(err){
        throw err;
    }
    console.log(js); // valid js.
});

You can alternatively use jsn.parseFile(path, model, callback) to use a template file directly, instead.

This is particularly useful when you have small pieces of data you want to pass to your JavaScript files. It's often most useful when paired with node-assetify, which supports jsn out the box.

To keep things simple, JSN supports only context variable names with [A-z], [0-9], -, or _ characters. @ characters can be escaped using @@.

About

JavaScript Node server-side variable parser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published