Skip to content

Instantly share code, notes, and snippets.

@dagda1
Created February 9, 2012 16:08
Show Gist options
  • Save dagda1/1780841 to your computer and use it in GitHub Desktop.
Save dagda1/1780841 to your computer and use it in GitHub Desktop.
ember_handlebars.rb
require 'tilt'
require 'json'
class EmberHandlebars < Tilt::Template
def self.default_mime_type
"application/javascript"
end
def prepare
end
def evaluate(scope, locals, &block)
"Ember.TEMPLATES['#{scope.logical_path}'] = Ember.Handlebars.compile(#{data.to_json})"
end
end
# Rails
Rails.application.assets.engines['handlebars'] = HandlebarsTemplate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment