hbs-helpers-sync

0.1.7 • Public • Published

npm version

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`

License

MIT License

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.7
    1
    • latest

Version History

Package Sidebar

Install

npm i hbs-helpers-sync

Weekly Downloads

8

Version

0.1.7

License

MIT

Last publish

Collaborators

  • duivvv