mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FIX: Raw templates in customizations were broken
This commit is contained in:
@ -44,14 +44,18 @@ PLUGIN_API_JS
|
|||||||
name = node["name"] || node["data-template-name"] || "broken"
|
name = node["name"] || node["data-template-name"] || "broken"
|
||||||
precompiled =
|
precompiled =
|
||||||
if name =~ /\.raw$/
|
if name =~ /\.raw$/
|
||||||
"RawHandlebars.template(#{Barber::Precompiler.compile(node.inner_html)})"
|
"require('discourse/lib/raw-handlebars').template(#{Barber::Precompiler.compile(node.inner_html)})"
|
||||||
else
|
else
|
||||||
"Ember.HTMLBars.template(#{Barber::Ember::Precompiler.compile(node.inner_html)})"
|
"Ember.HTMLBars.template(#{Barber::Ember::Precompiler.compile(node.inner_html)})"
|
||||||
end
|
end
|
||||||
compiled = <<SCRIPT
|
|
||||||
Ember.TEMPLATES[#{name.inspect}] = #{precompiled};
|
node.replace <<COMPILED
|
||||||
SCRIPT
|
<script>
|
||||||
node.replace("<script>#{compiled}</script>")
|
(function() {
|
||||||
|
Ember.TEMPLATES[#{name.inspect}] = #{precompiled};
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
COMPILED
|
||||||
end
|
end
|
||||||
|
|
||||||
doc.css('script[type="text/discourse-plugin"]').each do |node|
|
doc.css('script[type="text/discourse-plugin"]').each do |node|
|
||||||
|
@ -109,8 +109,8 @@ HTML
|
|||||||
c = SiteCustomization.create!(user_id: -1, name: "test", head_tag: with_template, body_tag: with_template)
|
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.head_tag_baked).to match(/HTMLBars/)
|
||||||
expect(c.body_tag_baked).to match(/HTMLBars/)
|
expect(c.body_tag_baked).to match(/HTMLBars/)
|
||||||
expect(c.body_tag_baked).to match(/RawHandlebars/)
|
expect(c.body_tag_baked).to match(/raw-handlebars/)
|
||||||
expect(c.head_tag_baked).to match(/RawHandlebars/)
|
expect(c.head_tag_baked).to match(/raw-handlebars/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should create body_tag_baked on demand if needed' do
|
it 'should create body_tag_baked on demand if needed' do
|
||||||
|
Reference in New Issue
Block a user