Skip to content

Commit

Permalink
Merge pull request #25 from jaredwray/exporting-handelbar-helpers-to-…
Browse files Browse the repository at this point in the history
…make-it-easier-to-use-via-handlebarHelpers

exporting handelbar helpers to make it easier to use via handlebarHel…
  • Loading branch information
jaredwray committed Oct 2, 2023
2 parents fa1d1a4 + 636838e commit fdaf80a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Handlebars + Helpers Together

## Table of Contents
* [Using in Nodejs](#using-in-nodejs)
* [Just using Handlebar Helpers](#using-handlebars-helpers)
* [Helpers](#helpers)
* [How to Contribute](#how-to-contribute)
* [License and Copyright](#license-and-copyright)
Expand All @@ -34,6 +35,20 @@ console.log(html);

It's just that easy! No need to add Handlebars to your project, it's already included.

## Using Handlebars Helpers

If you only want to use handlebar helpers you can easily do that by doing the following:

```javascript
var helpers = require('@jaredwray/fumanchu').handlebarHelpers;
var handlebars = require('handlebars');
helpers({ handlebars: handlebars });
var fn = handlebars.compile('{{add value 5}}');
console.log(fn);
```

Notice that in this scenario you are accessing helpers via `handlebarHelpers` from `fumanchu` instead of just using handlebars via fumanchu directly.

## Helpers
More than 180 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate, Verb, Ghost, gulp-handlebars, grunt-handlebars, consolidate, or any node.js/Handlebars project.

Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ const handlebars = HandlebarsLib.create();
helpers({ handlebars: handlebars });

module.exports = handlebars;
module.exports.handlebarHelpers = helpers;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@jaredwray/fumanchu",
"description": "Handlebars + Helpers = Fumanchu",
"version": "1.0.3",
"version": "1.1.0",
"homepage": "https://github.com/jaredwray/fumanchu",
"author": "Jared Wray (me@jaredwray.com)",
"keywords": [
Expand Down
9 changes: 9 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,14 @@ describe('Fumanchu Template Test', function() {
var fn = Fumanchu.compile('{{add value 5}}');
assert.equal(fn({value: 5}), '10');
});

it('should have the helper class exported', function() {
var helpers = require('../index.js').handlebarHelpers;
const HandlebarsLib = require('handlebars');
const handlebars = HandlebarsLib.create();
helpers({ handlebars: handlebars });
var fn = handlebars.compile('{{add value 5}}');
assert.equal(fn({value: 5}), '10');
});
});

0 comments on commit fdaf80a

Please sign in to comment.