Flight.js mixin for using handlebars.js templates with a component
npm install flight-handlebars-viewA Flight mixin for Handlebars templating with Components.
With Bower:
``bash`
$ bower install --save flight-handlebars-view
With npm:
`bash`
$ npm install flight-handlebars-view --save-dev
for Flight.js components to use so they can implement all or part of their DOM behavior using Handlebars.js client-side templates. It is __not__ a Component by itself. A number of other flight templating mixins for Hogan, Mustache and others include a full Component piece along with a Mixin. They do this to abstract the entire managing of templates to a data/utility type mixin that attaches to the DOM and then listens for requests for templates from UI Components. The templates, rather their rendered html, is then sent back to the requesting UI Component via an event.
This approach has the drawback of tightly coupling the utility, template serving Component to any UI Component that wants to use the Mixin to render templates. Not to mention it makes us add another Component to the page and generate more events when the UI is rendering.
The approach taken here is to remove the data/utility Component all together, and thereby remove any dependency for other UI Components that want to use Handlebars templates to manage their DOM behavior. Let the UI Component manage their templates directly, as you already have Handlebars included on the page in the first place.
Requirements
This mixin can be used with Flight.js via Require.js or using standalone Flight.js.
You only need to include/require Handlebars.js library (_full or just the runtime if using only pre-compiled templates_) for this mixin to work.
API
####
Render({String}, {Object})
Use the with_handlebars_view mixin. The mixin provides any Component with a render() method. Then render method has the following signature:+ {string} _html_ = this->render({string} _name_, {object} _context_)
Where:
+ {string} _name_ - the property in
this.attr.templates that references the specific template. A template can be referenced as any of the following:
1. an inline, string template
2. an '#' id selector referencing a template in a `
Development of this component requires Bower, and preferably
Karma to be globally installed:
`bash`
npm install -g bower karma
Then install the Node.js and client-side dependencies by running the following
commands in the repo's root directory.
`bash`
npm install
bower install
To continuously run the tests in Chrome and Firefox during development, just run:
`bash``
karma start
Anyone and everyone is welcome to contribute. Please take a moment to
review the guidelines for contributing.