Ember helpers for HTMLBars
npm install @timkendrick/ember-htmlbars-helpers> Ember helpers for HTMLBars
``bash`
npm install @timkendrick/ember-htmlbars-helpers
Ember templates are executed by HTMLBars, an HTML-friendly version of Handlebars.
Ember comes pre-loaded with a selection of HTMLBars helpers, however these are distributed as part of the Ember source code and cannot easily be used outside Ember apps.
This is an effort to package up some of those core helpers, allowing HTMLBars to be used productively in a non-Ember environment.
When rendering an HTMLBars template, set the helpers property on the env object:
`javascript
var helpers = require('@timkendrick/ember-htmlbars-helpers');
var compiler = require('htmlbars/dist/cjs/htmlbars-compiler');
var hooks = require('htmlbars/dist/cjs/htmlbars-runtime').hooks;
var render = require('htmlbars/dist/cjs/htmlbars-runtime').render;
var DOMHelper = require('htmlbars/dist/cjs/dom-helper');
var source = '{{#if foo}}Helpers loaded!{{/if}}';
var data = { foo: true };
var compileOptions = {};
var template = compiler.compile(source, compileOptions);
var env = {
dom: new DOMHelper(),
hooks: hooks,
helpers: helpers
};
var result = template.render(env, scope, { contextualElement: document.body });
var dom = result.fragment;
document.body.appendChild(dom);
`
Documentation for each helper can be found in the Ember API reference.
- each-in
- each
- get
- if
- log
- unless
- with`
Copyright (c) 2015 Yehuda Katz, Tom Dale and Ember.js contributors