socket_chat_example/node_modules/grunt-ember-handlebars at master · maxsap/socket_chat_example · GitHub
Skip to content

Latest commit

 

History

History
 
 

grunt-ember-handlebars

Folders and files

README.md

grunt-ember-handlebars

Precompile ember templates in grunt using only headless-ember.js and ember.js.

Installation

  1. Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-ember-handlebars

  2. Then add this line to your project's grunt.js gruntfile:

grunt.loadNpmTasks('grunt-ember-handlebars');

Usage

In your gruntfile.js:

grunt.initConfig({

  // Compile ember templates:
  ember_handlebars: {
    all: {
      // In practice, this could be:
      // src: ['templates/**/*.hbs', 'templates/**/*.handlebars']
      src: ['templates/main.hbs', 'templates/post.handlebars'],
      dest: 'templates/compiled'
    }
  },

  // Include the templates in your app:
  concat: {
    all: {
      src: ['templates/compiled/*.js', 'app.js'],
      dest: 'public/myapp.js'
    }
  }

});

// Load the plugin. This assumes you have installed it via NPM.
grunt.loadNpmTasks('grunt-ember-handlebars');
grunt.registerTask('default', ['ember_handlebars', 'concat']);

Run the task using grunt, and grunt-ember-handlebars will compile and include the templates using Ember.TEMPLATES. Now, just use them in your views:

App.MainView = Em.View.extend({
  templateName: 'main'
});

App.PostView = Em.View.extend({
  templateName: 'post'
});
// etc.

That's it!

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style.

Release History

v0.4 - Updated ember.js library we're using, since it looks like precompilation has been updated.

v0.1 - Woo!

License

Copyright (c) 2012 Mukund Lakshman

Licensed under the MIT license.