Novice, Practiced, Mastered
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    jsonrenderpublic

    Jsonrender

    jsonrender is a

    • Stream wrapper around the mustache handlebars implementation
    • Command line tool for rendering handlebars templates
    • A very small node module that wraps around handlebars to offer an express-like mechanism for embedding a body temlpate inside a layout template

    Usage

    As a module

    var jsonrender = require('jsonrender');
    var template = '<foo>{{bar}}</foo>';
    var layout = '<baz>{{>body}}</baz>';
    var render = jsonrender.compile(template);
    var renderWithLayout = jsonrender.compile(template, layout);
     
    console.log(render({ bar: 'buh' }));
    // '<foo>buh</foo>' 
     
    console.log(renderWithLayout({ bar: 'buh' });
    // '<baz><foo>buh</foo></baz>' 

    As a command line utility

    $ cat template.hbs
    <h1>{{title}}</h1>
     
    $ cat layout.hbs
    <head></head><body>{{>body}}</body>
     
    $ echo '{title: "The Title"}' | jsonrender --template template.hbs
    <h1>The Title</h1>
     
    $ echo '{title: "The Title"}' | jsonrender --template template.hbs \
      --layout layout.hbs
    <head></head><body><h1>The Title</h1></body> 

    Keywords

    none

    install

    npm i jsonrender

    Downloadsweekly downloads

    3

    version

    0.2.1

    license

    none

    last publish

    collaborators

    • avatar