diff --git a/app/models/site_customization.rb b/app/models/site_customization.rb
index b85ef907e61..57bc6319d00 100644
--- a/app/models/site_customization.rb
+++ b/app/models/site_customization.rb
@@ -44,14 +44,18 @@ PLUGIN_API_JS
name = node["name"] || node["data-template-name"] || "broken"
precompiled =
if name =~ /\.raw$/
- "RawHandlebars.template(#{Barber::Precompiler.compile(node.inner_html)})"
+ "require('discourse/lib/raw-handlebars').template(#{Barber::Precompiler.compile(node.inner_html)})"
else
"Ember.HTMLBars.template(#{Barber::Ember::Precompiler.compile(node.inner_html)})"
end
- compiled = <")
+
+ node.replace <
+ (function() {
+ Ember.TEMPLATES[#{name.inspect}] = #{precompiled};
+ })();
+
+COMPILED
end
doc.css('script[type="text/discourse-plugin"]').each do |node|
diff --git a/spec/models/site_customization_spec.rb b/spec/models/site_customization_spec.rb
index 2495e1ebcc8..e762c78d547 100644
--- a/spec/models/site_customization_spec.rb
+++ b/spec/models/site_customization_spec.rb
@@ -109,8 +109,8 @@ HTML
c = SiteCustomization.create!(user_id: -1, name: "test", head_tag: with_template, body_tag: with_template)
expect(c.head_tag_baked).to match(/HTMLBars/)
expect(c.body_tag_baked).to match(/HTMLBars/)
- expect(c.body_tag_baked).to match(/RawHandlebars/)
- expect(c.head_tag_baked).to match(/RawHandlebars/)
+ expect(c.body_tag_baked).to match(/raw-handlebars/)
+ expect(c.head_tag_baked).to match(/raw-handlebars/)
end
it 'should create body_tag_baked on demand if needed' do