helpers / handlebars-helpers

188 handlebars helpers in ~20 categories. Can be used with Assemble, Ghost, YUI, express.js etc.
http://assemble.io/helpers/
MIT License
2.22k stars 364 forks source link

Replacing Swag with handlebars-helpers #358

Closed karlitos closed 4 years ago

karlitos commented 4 years ago

I'd like to migrate from the Swag library to handlebar helpers, since Swag is unmaintained and depends ob old and vunnerable version of Handlebars. My app depends on Handlebars and HandlebarsAsync and I use Swag like this:

const promisedHandlebars = require('promised-handlebars');
const HandlebarsAsync = promisedHandlebars(require('handlebars'));
const Handlebars = require('handlebars');
const Swag = require('swag');

...

// Register swag handlebars helpers
Swag.registerHelpers(HandlebarsAsync);
Swag.registerHelpers(Handlebars);

How should it look like with handlebars-helpers ?

doowb commented 4 years ago

See the Optionally pass your own handlebars section under Usage.

const helpers = require('handlebars-helpers');
helpers({ handlebars: HandlebarsAsync });
helpers({ handlebars: Handlebars });

The return value from the helpers function above is just the object of registered helpers on the Handlebars instance that you passed in. I'm not sure how promised-handlebars works, so you might run into issues that don't have anything to do with this library (handlebars-helpers).

karlitos commented 4 years ago

Many thanks I will give it a try.