Compile Handlebars templates for Ember in Grunt. Features destination:source file arguments and customizable template names.
Precompile Handlebars templates for Ember.js.
This plugin requires Grunt
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-ember-templates --save-dev
Gruntfile.js file, add a section named
emberTemplates. This section specifies the files to compile and the options used with handlebars.
This defines what files this task will process and should contain key:value pairs.
Note: Values are precompiled to the
Ember.TEMPLATES array in the order passed.
This controls how this task operates and should contain key:value pairs, see options below.
This option accepts a function which takes one argument (the source template filepath) and returns a string which will be used as the key for the precompiled template object. The example below strips away the root path from templates so their names will match Ember's conventions:
options:return sourceFilereplace/path\/to\/templates\// '';
emberTemplates:compile:options:return sourceFilereplace/path\/to\// '';files:"path/to/result.js": "path/to/source.handlebars""path/to/another.js": "path/to/sources/*.handlebars" "path/to/more/*.handlebars"
Here's an example task that watches for changes to your templates and automatically recompiles them:
watch:emberTemplates:files: 'app/scripts/**/*.handlebars'tasks: 'emberTemplates' 'livereload'
Many thanks to the following projects upon which this was based:
I created this project as an alternative to grunt-ember-handlebars for the following reasons:
ember_templatestask in favor of