A Mincer engine to for serving Ember-friendly Handlebars templates.
Mincer is a badass JavaScript port of Sprockets that makes it super-duper easy to serve dynamically generated assets in your connect or express app. You'll want to be familiar with its use before you try using this package.
Note*: this engine overrides the built-in Handlebars engine. Furthermore, there is no need to pair your template files with the built-in JST engine. Naming your files [my-template].hbs
will do.
First, install the package:
npm install mincer-ember-hbs-engine --save
Then, wherever you've set up your Mincer environment:
// Requirements
var mincer = require('mincer');
var mincerEmberHbs = require('mincer-ember-hbs-engine');
// Asset pipeline
var pipeline = new mincer.Environment();
pipeline.registerEngine('.hbs', mincerEmberHbs);
Assuming a directory structure similar to this…
app/
assets/
javascripts/
templates/
application.hbs
home.hbs
templates.js
…you can now create a manifest for your templates, like this:
app/assets/javascripts/templates.js
//= require_tree ./templates
Not to fear, Ember handles defining Ember.TEMPLATES
as an empty object. Make sure that your templates aren't instantiated before Ember and you'll be A-OK.
At this time, the only way to achieve that would be to register this engine under a different file extension, leaving the default .hbs
engine intact.
Uproarious applause goes to @ixti and @puzrin for their incredible work on Mincer. Further thanks for @Nthalk for a great example of a simple Mincer engine.
Mike Fowler (@michaelrfowler on Twitter)
Copyright (c) 2014 Mike Fowler
Released under the MIT license. See LICENSE for details.