broadway-handlebars
Advanced tools
Comparing version 0.4.1 to 0.4.2
27
index.js
@@ -10,3 +10,3 @@ // var _ = { | ||
var handlebars = require('handlebars'); // parens will prevent browserify from packaging. | ||
var defaultViewResolver = (typeof(window) === 'undefined') ? require('./viewresolver') : null; | ||
var defaultViewResolver = !process.browser ? require('./viewresolver') : null; | ||
@@ -33,3 +33,3 @@ var bwHandlebars = function() { }; | ||
view: { | ||
base: (typeof(window) === 'undefined') ? process.cwd() : null, | ||
base: process.cwd(), | ||
ext: "html" | ||
@@ -117,2 +117,21 @@ } | ||
// Allowing dynamic loading of partials based on value of variable in context | ||
// Call is made like {{{partial "partial.root" partial_name ctx}}} or {{{partial full_partial_string ctx}}} | ||
Handlebars.registerHelper('partial', function(root, name, ctx, hash) { | ||
var ps = Handlebars.partials, path; | ||
if (typeof name === 'object') { | ||
var tmp = name; | ||
name = ''; | ||
hash = ctx; | ||
ctx = tmp; | ||
} else if (typeof name === 'undefined') { | ||
name = ''; | ||
}; | ||
path = root + ((name !== '') ? ('.' + name) : name); | ||
if(typeof ps[path] != 'function') | ||
ps[path] = Handlebars.compile(ps[path]); | ||
return ps[path](ctx, hash); | ||
}); | ||
// Inject external handlebar helpers. | ||
@@ -171,3 +190,5 @@ _.each(options.helpers, function(fn, name) { | ||
templateCache[view] = markup ? Handlebars.compile(markup) : function() { throw new Error("View Not Found - " + view); }; | ||
templateCache[view] = markup ? Handlebars.compile(markup) : function() { | ||
logger.error("View Not Found - " + view); | ||
}; | ||
return templateCache[view]; | ||
@@ -174,0 +195,0 @@ }; |
{ | ||
"name": "broadway-handlebars", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"main": "index", | ||
@@ -5,0 +5,0 @@ "description": "Plugin for flatiron/broadway for rendering with the handlebars view engine.", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
12335
325
5