lib/hbs.js
function render(template, locals, layoutTemplates, cb) {
    if (!layoutTemplates) layoutTemplates = [];

    // We'll render templates from bottom to top of the stack, each template
    // being passed the rendered string of the previous ones as `body`
    var i = layoutTemplates.length - 1;

    var _stackRenderer = function(err, htmlStr) {
      if (err) return cb(err);

      if (i >= 0) {
        locals.body = htmlStr;
        renderTemplate(layoutTemplates[i--], locals, _stackRenderer);
      } else {
        cb(null, htmlStr);
      }
    };

    // Start the rendering with the innermost page template
    renderTemplate(template, locals, _stackRenderer);
  }
function render(template, locals, layoutTemplates, cb) {
    if (!layoutTemplates) layoutTemplates = [];

    // We'll render templates from bottom to top of the stack, each template
    // being passed the rendered string of the previous ones as `body`
    var i = layoutTemplates.length - 1;

    var _stackRenderer = function(err, htmlStr) {
      if (err) return cb(err);

      if (i >= 0) {
        locals.body = htmlStr;
        renderTemplate(layoutTemplates[i--], locals, _stackRenderer);
      } else {
        cb(null, htmlStr);
      }
    };

    // Start the rendering with the innermost page template
    renderTemplate(template, locals, _stackRenderer);
  }
function render ( template , locals , layoutTemplates , cb ) { if ( ! layoutTemplates ) layoutTemplates = [ ] ; // We'll render templates from bottom to top of the stack, each template // being passed the rendered string of the previous ones as `body` var i = layoutTemplates . length - 1 ; var _stackRenderer = function ( err , htmlStr ) { if ( err ) return cb ( err ) ; if ( i >= 0 ) { locals . body = htmlStr ; renderTemplate ( layoutTemplates [ i -- ] , locals , _stackRenderer ) ; } else { cb ( null , htmlStr ) ; } } ; // Start the rendering with the innermost page template renderTemplate ( template , locals , _stackRenderer ) ; }
Renders `template` with an optional set of nested `layoutTemplates` using
data in `locals`.
Renders template with an optional set of nested layoutTemplates using data in locals .