hbs-helpers-sync
v0.1.7
Published
sync Handlebars helpers between server and client
Downloads
10
Maintainers
Readme
hbs-helpers-sync
if you use express-handlebars you can use hbs-helpers-sync to make all your server-side helpers available to your client side
Usage
I advice you to use it with Browserify as a client side NPM module
NPM
npm install --save-dev hbs-helpers-sync
Bower
bower install --save hbs-helpers-sync
Example
var runtime = require("hbsfy/runtime");
var HHS = require("hbs-helpers-sync");
//server helpers file
var helpers = require("../../config/helpers.js");
HHS.sync({
helpers: helpers,
Handlebars: runtime
exclude: [
'section',
'formatDate'
]
});
Parameters
helpers [required]
helpers object with helper functions
in express-handlebars format
// ...
var helpers = require("../../config/helpers.js");
HHS.sync({
helpers: helpers,
});
helpers.js (server-side helpers)
{
foo: function () { return 'FOO!'; },
bar: function () { return 'BAR!'; }
}
Type: `Object`
Handlebars [optional]
reference to Handlebars runtime
// ...
var runtime = require("hbsfy/runtime");
HHS.sync({
helpers: helpers,
Handlebars: runtime
});
Type: `Object`
default: window.Handlebars
exclude [optional]
which helper(s) to exclude
// ...
HHS.sync({
helpers: helpers,
Handlebars: runtime,
exclude: 'section'
});
Type: `String|Array`
include [optional]
explicit list which helper(s) to include, ignores exclude parameter
// ...
HHS.sync({
helpers: helpers,
Handlebars: runtime,
include: [
'formatDate',
'formatText'
]
});
Type: `String|Array`