A platform for community discussion. Free, open, simple.
FIX: Prevent double slashes in Ember templates paths (#12630)
Osama Sayegh105634435fe6
diff --git a/app/models/theme.rb b/app/models/theme.rbindex 4803f1d4040..ef935774fa1 100644--- a/app/models/theme.rb+++ b/app/models/theme.rb@@ -128,7 +128,7 @@ class Theme < ActiveRecord::BaseSvgSprite.expire_cacheend- BASE_COMPILER_VERSION = 45+ BASE_COMPILER_VERSION = 46def self.compiler_versionget_set_cache "compiler_version" dodependencies = [diff --git a/lib/theme_javascript_compiler.rb b/lib/theme_javascript_compiler.rbindex 49178655c2a..6fb33e7126f 100644--- a/lib/theme_javascript_compiler.rb+++ b/lib/theme_javascript_compiler.rb@@ -183,7 +183,11 @@ class ThemeJavascriptCompiler# TODO Error handling for handlebars templatesdef append_ember_template(name, hbs_template)- name = "javascripts/#{name}" if !name.start_with?("javascripts/")+ if !name.start_with?("javascripts/")+ prefix = "javascripts"+ prefix += "/" if !name.start_with?("/")+ name = prefix + name+ endname = name.inspectcompiled = EmberTemplatePrecompiler.new(@theme_id).compile(hbs_template)# the `'Ember' in window` check is needed for no_ember pagesdiff --git a/spec/lib/theme_javascript_compiler_spec.rb b/spec/lib/theme_javascript_compiler_spec.rbindex e82bb645977..e15adc5ee05 100644--- a/spec/lib/theme_javascript_compiler_spec.rb+++ b/spec/lib/theme_javascript_compiler_spec.rb@@ -127,4 +127,18 @@ describe ThemeJavascriptCompiler doexpect(compiler.content.to_s).to include("addRawTemplate(\"#{name}.hbs\"")endend++ describe "#append_ember_template" do+ let(:compiler) { ThemeJavascriptCompiler.new(1, 'marks') }+ it 'prepends `javascripts/` to template name if it is not prepended' do+ compiler.append_ember_template("/connectors/blah-1", "{{var}}")+ expect(compiler.content.to_s).to include('Ember.TEMPLATES["javascripts/connectors/blah-1"]')++ compiler.append_ember_template("connectors/blah-2", "{{var}}")+ expect(compiler.content.to_s).to include('Ember.TEMPLATES["javascripts/connectors/blah-2"]')++ compiler.append_ember_template("javascripts/connectors/blah-3", "{{var}}")+ expect(compiler.content.to_s).to include('Ember.TEMPLATES["javascripts/connectors/blah-3"]')+ end+ endend