Skip to content

Commit

Permalink
feat(engine-handlebars): Document the Helpers feature
Browse files Browse the repository at this point in the history
  • Loading branch information
engelfrost committed Oct 11, 2018
1 parent 11c4180 commit a01e040
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion packages/engine-handlebars/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The Handlebars PatternEngine for Pattern Lab / Node

To install the Handlebars PatternEngine in your edition, `npm install @pattern-lab/engine-handlebars` should do the trick.
To install the Handlebars PatternEngine in your edition, `npm install --save @pattern-lab/engine-handlebars` should do the trick.

## Supported features

Expand All @@ -11,3 +11,34 @@ To install the Handlebars PatternEngine in your edition, `npm install @pattern-l
* [x] [Pattern States](http://patternlab.io/docs/pattern-states.html)
* [ ] [Pattern Parameters](http://patternlab.io/docs/pattern-parameters.html) (Accomplished instead using [native Handlebars partial arguments](http://handlebarsjs.com/partials.html))
* [ ] [Style Modifiers](http://patternlab.io/docs/pattern-stylemodifier.html) (Accomplished instead using [native Handlebars partial arguments](http://handlebarsjs.com/partials.html))

## Helpers

To add custom [helpers](http://handlebarsjs.com/#helpers) or otherwise interact with Handlebars directly, create a file named `patternlab-handlebars-config.js` in the root of your Pattern Lab project, or override the default location by specifying one or several glob patterns in the Pattern Lab config:

```json
{
...
"engines": {
"handlebars": {
"helpers": [
"handlebars-helpers.js",
"helpers/**/*.js"
]
}
}
}
```

Each file should export a function which takes Handlebars as an argument.

```js
module.exports = function(Handlebars) {
// Put helpers here

Handlebars.registerHelper('fullName', function(person) {
// Example: person = {firstName: "Alan", lastName: "Johnson"}
return person.firstName + " " + person.lastName;
});
};
```

0 comments on commit a01e040

Please sign in to comment.