discourse/lib/freedom_patches/better_handlebars_errors.rb

Failed to ignore revisions in .git-blame-ignore-revs.

18 lines
558 B
Ruby
Raw Normal View History

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