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.
JavaScript
Switch branches/tags
Nothing to show
Latest commit 4502e20 Mar 13, 2015 @jonschlinkert jonschlinkert 0.2.0
Permalink
Failed to load latest commit information.
.editorconfig lint Mar 13, 2015
.gitattributes lint Mar 13, 2015
.gitignore lint Mar 13, 2015
.jshintrc lint Mar 13, 2015
.travis.yml lint Mar 13, 2015
.verb.md generate readme Mar 14, 2015
LICENSE lint Mar 13, 2015
README.md generate readme Mar 14, 2015
index.js refactor Mar 14, 2015
package.json 0.2.0 Mar 14, 2015
test.js refactor Mar 14, 2015

README.md

handlebars-helper-partial NPM version Build Status

Handlebars helper for rendering partials.

Install with npm

npm i handlebars-helper-partial --save

Usage

var helper = require('handlebars-helper-partial');

Handlebars example

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', '<button>{{text}}</button>');

// 4. use in templates
handlebars.compile('{{partial "button"}}')({text: 'Click me!'});
//=> '<button>Click me!</button>'

Pass a specific context to the partial:

handlebars.compile('{{partial "button" a.b.c}}')({a: {b: c: {text: 'Click me!'}}});
//=> '<button>Click me!</button>'

Related projects

  • 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: 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.

npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb-cli on March 13, 2015.