FIX: Raw templates in customizations were broken

This commit is contained in:
Robin Ward 2016-07-06 12:27:12 -04:00
parent ff4e60808a
commit c1d4ca4031
2 changed files with 11 additions and 7 deletions

View File

@ -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 = <<SCRIPT
Ember.TEMPLATES[#{name.inspect}] = #{precompiled};
SCRIPT
node.replace("<script>#{compiled}</script>")
node.replace <<COMPILED
<script>
(function() {
Ember.TEMPLATES[#{name.inspect}] = #{precompiled};
})();
</script>
COMPILED
end
doc.css('script[type="text/discourse-plugin"]').each do |node|

View File

@ -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