Skip to content

Instantly share code, notes, and snippets.

@gnepud
Forked from dagda1/ember_handlebars.rb
Created June 8, 2012 08:09
Show Gist options
  • Save gnepud/2894403 to your computer and use it in GitHub Desktop.
Save gnepud/2894403 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