Skip to content

Instantly share code, notes, and snippets.

@danmartens
Created April 2, 2014 14:25
Show Gist options
  • Save danmartens/9935208 to your computer and use it in GitHub Desktop.
Save danmartens/9935208 to your computer and use it in GitHub Desktop.
Ember Template Helper
###
# <%= ember_template 'greeting' do %>
# Hello {{name}}!
# <% end %>
###
module EmberHelper
include ActionView::Helpers::CaptureHelper
def ember_template(name, &block)
content = capture(&block)
template = Barber::Ember::InlinePrecompiler.call(content)
content_tag(:script, raw("Ember.TEMPLATES['#{name}'] = #{template};"), type: 'text/javascript')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment