Class: Ember::Handlebars::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/freedom_patches/better_handlebars_errors.rb

Instance Method Summary collapse

Instance Method Details

#compile_ember_handlebars(string, ember_template = "Handlebars", options = nil) ⇒ Object

Wrap in an IIFE in development mode to get the correct filename



7
8
9
10
11
12
13
# File 'lib/freedom_patches/better_handlebars_errors.rb', line 7

def compile_ember_handlebars(string, ember_template = "Handlebars", options = nil)
  if ::Rails.env.development?
    "(function() { try { return Ember.#{ember_template}.compile(#{indent(string).inspect}); } catch(err) { throw err; } })()"
  else
    "Ember.#{ember_template}.compile(#{indent(string).inspect}, #{options.to_json});"
  end
end