Short answer, you can currently (v0.7.10) supply only one parameter in express-hbs.
, , JSON , JSON.parse(), . .
:.
hbs.registerAsyncHelper( 'ads', function(arg, cb) {
var options = JSON.parse(arg);
console.log(options);
cb( new hbs.SafeString( ' == ADS == ' ) );
});
{{{ads "[\"page-x\",\"vertical\",\"256x56\"]" }}}
-hbs:
;
express-hbs registerAsyncHelper:
ExpressHbs.prototype.registerAsyncHelper = function(name, fn) {
this.handlebars.registerHelper(name, function(context) {
return async.resolve(fn.bind(this), context);
});
};
() handlebars.registerHelper, . , :
ExpressHbs.prototype.registerAsyncHelper = function(name, fn) {
this.handlebars.registerHelper(name, function(contextArgs) {
return async.resolve(fn.bind(this), Array.prototype.slice.call(contextArgs));
});
};
. , .
, , - . , ( handlebars-hbs ):
{{{ads 'page-x' 'vertical' '256x56'}}}