2014-12-11 00:34:00 +08:00
|
|
|
module Ember
|
|
|
|
module Handlebars
|
2016-04-18 10:47:52 +08:00
|
|
|
class Template
|
2014-12-11 00:34:00 +08:00
|
|
|
|
|
|
|
# Wrap in an IIFE in development mode to get the correct filename
|
2016-04-18 10:47:52 +08:00
|
|
|
def compile_ember_handlebars(string, ember_template = 'Handlebars', options = nil)
|
2014-12-11 00:34:00 +08:00
|
|
|
if ::Rails.env.development?
|
2015-05-07 22:52:31 +08:00
|
|
|
"(function() { try { return Ember.#{ember_template}.compile(#{indent(string).inspect}); } catch(err) { throw err; } })()"
|
2014-12-11 00:34:00 +08:00
|
|
|
else
|
2016-04-18 10:47:52 +08:00
|
|
|
"Ember.#{ember_template}.compile(#{indent(string).inspect}, #{options.to_json});"
|
2014-12-11 00:34:00 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|