Assemble and pre-compile your Handlebars templates on the server side
JavaScript
Switch branches/tags
Nothing to show
Pull request Compare This branch is 8 commits ahead, 50 commits behind nicjansma:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test_views
.gitignore
README.mkdn
handlebars-precompiler.js
package.json
test.js

README.mkdn

Precompile Handlebars Template directories

This is how you might use it in an Express project.

app.configure('development', function(){
  require('./lib/handlebars-precompiler').compile({
    src: __dirname + '/views', 
    dest: __dirname + '/public/javascripts/templates.js',
    extensions: ['handlebars', 'hbs'],
    minify: true, //run result through uglify-js
    watch: true, //recompile on file changes
    template_name: function(t) { return t.replace(/\//, '-'); } //callback to modify the template names
  });
});

In this example, we watch for changes to *.handlebars and *.hbs files in our views directory. When changes are made, precompilation is run on all Handlebars templates and exported to a single minified Javascript file.

On the browser side, you will have to include ember.js before the templates file.

Client-side versions of the templates will be named and stored in the Ember.TEMPLATES object according to their file paths, e.g. Ember.TEMPLATES['users/show'] you can change the template name using the template_name option above