node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


AJT (Ajax JSON Template)

How simple can it be to do an Ajax-Request, get JSON and put this into a template? Simple and lightweight: 3 KB!

ajt('', 'theTemplate', function (html) {
  document.getElementById('placeholder').innerHTML = html;

and your template is a vanillaJS compiled jade template :) - does that sound sweet? It does!

h2= value1
code= value2

That it, simple and intuitiv!


ajt is looking for three parameters, the request URL, the templateID and the callback. Everything else is done by ajt.js.


You can eitherway bundle it by using the node module, or the command line:

var ajt = require('ajt');
var js = ajt(__dirname + '/jadeTemplates', './optionalOutputfilename.js');
// ... 
$ ajt -t jadeTemplates -o myoutput.js
$ ajt -t jadeTemplates

You even can do:

$ ajt -t jadeTemplates -t moreTemplates -o myoutput.js