https://github.com/helpers/handlebars-helper-partial
Handlebars helper, alternative to built-in partials. Like Assemble itself, this helper will automatically determine the correct context to use, or a context may be explicitly passed in as a second parameter.
https://github.com/helpers/handlebars-helper-partial
Last synced: 9 months ago
JSON representation
Handlebars helper, alternative to built-in partials. Like Assemble itself, this helper will automatically determine the correct context to use, or a context may be explicitly passed in as a second parameter.
- Host: GitHub
- URL: https://github.com/helpers/handlebars-helper-partial
- Owner: helpers
- License: mit
- Created: 2013-12-31T08:32:17.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2015-03-14T02:04:24.000Z (almost 11 years ago)
- Last Synced: 2025-04-10T02:42:37.043Z (9 months ago)
- Language: JavaScript
- Size: 200 KB
- Stars: 16
- Watchers: 6
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# handlebars-helper-partial [](http://badge.fury.io/js/handlebars-helper-partial) [](https://travis-ci.org/helpers/handlebars-helper-partial)
> Handlebars helper for rendering partials.
## Install with [npm](npmjs.org)
```bash
npm i handlebars-helper-partial --save
```
## Usage
```js
var helper = require('handlebars-helper-partial');
```
## Handlebars example
```js
var handlebars = require('handlebars');
// 1. pass your instance of handlebars
var helper = require('handlebars-helper-partial')(handlebars);
// 2. register the helper, name it whatever you want
handlebars.registerHelper('partial', helper);
// 3. register some partials
handlebars.registerPartial('button', '{{text}}');
// 4. use in templates
handlebars.compile('{{partial "button"}}')({text: 'Click me!'});
//=> 'Click me!'
```
Pass a specific context to the partial:
```js
handlebars.compile('{{partial "button" a.b.c}}')({a: {b: c: {text: 'Click me!'}}});
//=> 'Click me!'
```
## Related projects
* [handlebars-helpers](https://github.com/assemble/handlebars-helpers): 120+ Handlebars helpers in ~20 categories, for Assemble, YUI, Ghost or any Handlebars project. Includes helpers like {{i18}}, {{markdown}}, {{relative}}, {{extend}}, {{moment}}, and so on.
* [template-helpers](https://github.com/jonschlinkert/template-helpers): Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or any engine that supports helper functions.
## Running tests
Install dev dependencies.
```bash
npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/helpers/handlebars-helper-partial/issues)
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 13, 2015._