PERF: stop loading handlebars and ember compilers in prod

(this removes a nice 50K from our initial payload and saves memory)

Also fixes invalid HTML automatically if added to HEAD or /BODY
This commit is contained in:
Sam
2015-11-27 11:58:46 +11:00
parent c8c6034a7a
commit 43d63367fd
9 changed files with 802 additions and 48 deletions

View File

@ -91,5 +91,32 @@ describe SiteCustomization do
expect(c.stylesheet_baked).not_to be_present
end
it 'should correct bad html in body_tag_baked and head_tag_baked' do
c = SiteCustomization.create!(user_id: -1, name: "test", head_tag: "<b>I am bold", body_tag: "<b>I am bold")
expect(c.head_tag_baked).to eq("<b>I am bold</b>")
expect(c.body_tag_baked).to eq("<b>I am bold</b>")
end
it 'should precompile fragments in body and head tags' do
with_template = <<HTML
<script type='text/x-handlebars' name='template'>
{{hello}}
</script>
<script type='text/x-handlebars' data-template-name='raw_template.raw'>
{{hello}}
</script>
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(/EmberCompatHandlebars/)
expect(c.head_tag_baked).to match(/EmberCompatHandlebars/)
end
it 'should create body_tag_baked on demand if needed' do
c = SiteCustomization.create!(user_id: -1, name: "test", head_tag: "<b>test", enabled: true)
c.update_columns(head_tag_baked: nil)
expect(SiteCustomization.custom_head_tag).to match(/<b>test<\/b>/)
end
end