template-bind-helpers
Bind the current instance of a Templates-based application to an object of helpers, allowing them to be passed to a different render method.
Last updated 5 years ago by jonschlinkert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install template-bind-helpers 
SYNC missed versions from official npm registry.

template-bind-helpers NPM version Build Status

Bind the current instance of a Templates-based application to an object of helpers, allowing them to be passed to a different render method.

Install

Install with npm

$ npm i template-bind-helpers --save

Usage

bindHelpers

Bind helper functions to app so that, when the helper is called, the this keyword is set to the provided instance of app.

Params

  • app {Object}: Instance of any [Templates-based][templates] application, such as verb, assemble or generate
  • view {Object}: The view being compiled or rendered
  • locals {Object}: Context object with helpers to bind. This is usually the options object.
  • isAsync {Boolean}
  • returns {Object}

Example

var bindHelpers = require('{%= name %}');
var str = '<%= replace("foo", "bar") %>';
opts = bindHelpers(this.app, opts, true);

// pass opts to a render method as context
app.render(str, opts, function(err, result) {
  console.log(result);
});

Related projects

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 © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb on December 11, 2015.

Current Tags

  • 0.2.0                                ...           latest (5 years ago)

4 Versions

  • 0.2.0                                ...           5 years ago
  • 0.1.2                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 17
This Month 59
Last Day 0
Last Week 18
Last Month 50
Dependencies (1)
Dev Dependencies (6)

Copyright 2014 - 2017 © taobao.org |