Pre-Compile Inline Handlebars Templates #65

sandstrom opened this Issue Jun 14, 2012 · 3 comments


None yet

3 participants


It's common to keep small handlebars templates inside the Javascript codebase, e.g. in views (example below). Would be nice if these would be pre-compiled in production, similar to how separate .hbs files are pre-compiled. Another benefit would be that the non-runtime part of handlebars could be skipped in production, reducing the file size.

Does this sound like a good idea? How could it be implemented?

Something similar exist in the ember-js Assetfile:

App.MyCustomSelect = Ember.View.extend({

  tagName: 'select',

  defaultTemplate: Ember.Handlebars.compile('{{#if view.prompt}}<option>{{view.prompt}}</option>{{/if}}{{#each view.content}}{{view Ember.SelectOption contentBinding="this"}}{{/each}}')

  etc: "...",

Ember.js member

I think this is a good idea.
Given current implementation we would need a custom sprockets processor.

@maedi maedi referenced this issue in tower/tower Sep 23, 2012

Merge default Templates into Views #307


Note to myself (and others).

This capability exist in the excellent Barber gem created by tchak. We'd have to hook into the generation of javascript files and look for Ember.handlebars.compile.

Ember.js member

This has gone stale, we can revisit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment