2014-10-29 12:24:51 +08:00
|
|
|
# barber patches to re-route raw compilation via ember compat handlebars
|
|
|
|
#
|
|
|
|
|
|
|
|
module Barber
|
|
|
|
class EmberCompatPrecompiler < Barber::Precompiler
|
|
|
|
|
|
|
|
def sources
|
|
|
|
[handlebars, precompiler]
|
|
|
|
end
|
|
|
|
|
|
|
|
def precompiler
|
|
|
|
@precompiler ||= StringIO.new <<END
|
|
|
|
var Discourse = {};
|
|
|
|
#{File.read(Rails.root + "app/assets/javascripts/discourse/lib/ember_compat_handlebars.js")}
|
|
|
|
var Barber = {
|
|
|
|
precompile: function(string) {
|
2014-12-11 11:52:42 +08:00
|
|
|
return Discourse.EmberCompatHandlebars.precompile(string,false).toString();
|
2014-10-29 12:24:51 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
END
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Ember::Handlebars::Template
|
|
|
|
def precompile_handlebars(string)
|
|
|
|
"Discourse.EmberCompatHandlebars.template(#{Barber::EmberCompatPrecompiler.compile(string)});"
|
|
|
|
end
|
|
|
|
def compile_handlebars(string)
|
|
|
|
"Discourse.EmberCompatHandlebars.compile(#{indent(string).inspect});"
|
|
|
|
end
|
|
|
|
end
|