Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

co-nested-hbs

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

co-nested-hbs - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

26

index.js

@@ -76,9 +76,21 @@ var fs = require('fs');

hbs.render = function* () {
var buffer=null, templates, locals, i, len, tmpl;
var buffer=null, lastArg, secondToLastArg, renderViewPath,
renderOpts, locals, templates, i, len, tmpl;
locals = arguments[arguments.length - 1];
lastArg = arguments[arguments.length - 1];
secondToLastArg = arguments[arguments.length - 2];
if (typeof locals === 'object') {
if (typeof secondToLastArg === 'object') {
// both renderOpts and locals given
renderOpts = lastArg;
locals = secondToLastArg;
templates = Array.prototype.slice.call(arguments, 0, -2);
} else if (typeof lastArg === 'object') {
// just locals given
renderOpts = {};
locals = lastArg;
templates = Array.prototype.slice.call(arguments, 0, -1);
} else {
// neither renderOpts nor locals given
renderOpts = {};
locals = {};

@@ -88,4 +100,8 @@ templates = Array.prototype.slice.call(arguments);

templates = templates.concat(hbs.layouts);
if (renderOpts.layout !== false) {
templates = templates.concat(hbs.layouts);
}
renderViewPath = renderOpts.viewPath || viewPath;
for(i = 0, len = templates.length; i < len; i++) {

@@ -96,3 +112,3 @@ tmpl = templates[i];

buffer = yield renderTemplate(viewPath, opts.partialsPath, tmpl, locals);
buffer = yield renderTemplate(renderViewPath, opts.partialsPath, tmpl, locals);
}

@@ -99,0 +115,0 @@

2

package.json
{
"name": "co-nested-hbs",
"version": "0.1.1",
"version": "0.2.0",
"repository": "speedmanly/co-nested-hbs",

@@ -5,0 +5,0 @@ "description": "Generator-based Handlebars templates for nested layouts.",

@@ -45,2 +45,11 @@ var assert = require('assert');

it('accepts locals and render options', function(done) {
co(function *() {
var view = require('..')('test'),
html = yield view.render('locals', {world: 'world'}, {layout: false});
assert.equal(html, 'hello world\n');
})(done);
});
it('finds and renders partials', function(done) {

@@ -69,2 +78,20 @@ co(function *() {

});
it('takes a last argument to disable the global layouts', function(done) {
co(function *() {
var view = require('..')('test', {layout: 'a'}),
html = yield view.render('c', {}, {layout: false});
assert.equal(html, 'c\n');
})(done);
});
it('takes a last argument to replace the default viewPath', function(done) {
co(function *() {
var view = require('..')('madeuppath'),
html = yield view.render('c', {}, {viewPath: 'test'});
assert.equal(html, 'c\n');
})(done);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc