A platform for community discussion. Free, open, simple.
FIX: Prevent duplicate params for raw template theme handlebars helpers
David Taylor95b5c5898ee5
diff --git a/app/models/theme_field.rb b/app/models/theme_field.rbindex 740eaf4dd69..7620129a005 100644--- a/app/models/theme_field.rb+++ b/app/models/theme_field.rb@@ -64,7 +64,7 @@ class ThemeField < ActiveRecord::Basevalidates :name, format: { with: /\A[a-z_][a-z0-9_-]*\z/i },if: Proc.new { |field| ThemeField.theme_var_type_ids.include?(field.type_id) }- COMPILER_VERSION = 9+ COMPILER_VERSION = 10belongs_to :themediff --git a/lib/theme_javascript_compiler.rb b/lib/theme_javascript_compiler.rbindex e01d7a6e841..7abe3f7da71 100644--- a/lib/theme_javascript_compiler.rb+++ b/lib/theme_javascript_compiler.rb@@ -64,11 +64,13 @@ class ThemeJavascriptCompilerfunction manipulateNode(node) {// Magically add theme id as the first param for each of these helpersif (node.path.parts && ["theme-i18n", "theme-prefix", "theme-setting"].includes(node.path.parts[0])) {- node.params.unshift({- type: "NumberLiteral",- value: #{@theme_id},- original: #{@theme_id}- })+ if(node.params.length === 1){+ node.params.unshift({+ type: "NumberLiteral",+ value: #{@theme_id},+ original: #{@theme_id}+ })+ }}// Override old themeSetting syntax when it's in its own nodediff --git a/spec/lib/theme_javascript_compiler_spec.rb b/spec/lib/theme_javascript_compiler_spec.rbindex 4bb011d6cff..3ae1fd110fd 100644--- a/spec/lib/theme_javascript_compiler_spec.rb+++ b/spec/lib/theme_javascript_compiler_spec.rb@@ -62,6 +62,12 @@ describe ThemeJavascriptCompiler doexpect(render("{{dummy-helper themeSettings.setting_key}}")).to eq('dummy(setting(22:setting_key))')end++ it "doesn't duplicate number parameter inside {{each}}" do+ expect(compiler.compile("{{#each item as |test test2|}}{{theme-setting 'setting_key'}}{{/each}}")).+ to include('{"name":"theme-setting","hash":{},"hashTypes":{},"hashContexts":{},"types":["NumberLiteral","StringLiteral"]')+ # Fail would be if theme-setting is defined with types:["NumberLiteral","NumberLiteral","StringLiteral"]+ endenddescribe ThemeJavascriptCompiler::EmberTemplatePrecompiler do