FIX: Correct deprecated theme settings in handlebars templates

FIX: Correct deprecated theme settings in handlebars templates

Was overriding the incorrect themeSetting.blah syntax, instead of themeSettings.blah

diff --git a/lib/theme_javascript_compiler.rb b/lib/theme_javascript_compiler.rb
index b4290d0..d5a11ca 100644
--- a/lib/theme_javascript_compiler.rb
+++ b/lib/theme_javascript_compiler.rb
@@ -54,7 +54,7 @@ class ThemeJavascriptCompiler
 
       function manipulatePath(path) {
         // Override old themeSetting syntax when it's a param inside another node
-        if(path.parts[0] == "themeSetting"){
+        if(path.parts[0] == "themeSettings"){
           const settingParts = path.parts.slice(1);
           path.type = "SubExpression";
           Object.assign(path, generateHelper(settingParts))
@@ -72,7 +72,7 @@ class ThemeJavascriptCompiler
         }
 
         // Override old themeSetting syntax when it's in its own node
-        if (node.path.parts[0] == "themeSetting") {
+        if (node.path.parts[0] == "themeSettings") {
           Object.assign(node, generateHelper(node.path.parts.slice(1)))
         }
       }
@@ -93,14 +93,14 @@ class ThemeJavascriptCompiler
         Handlebars.Compiler.prototype.compile = function(program, options) {
 
           // `replaceGet()` in raw-handlebars.js.es6 adds a `get` in front of things
-          // so undo this specific case for the old themeSetting.blah syntax
+          // so undo this specific case for the old themeSettings.blah syntax
           let visitor = new Handlebars.Visitor();
           visitor.mutating = true;
           visitor.MustacheStatement = (node) => {
             if(node.path.original == 'get'
               && node.params
               && node.params[0]
-              && node.params[0].parts[0] == 'themeSetting'){
+              && node.params[0].parts[0] == 'themeSettings'){
                 node.path.parts = node.params[0].parts
                 node.params = []
             }
diff --git a/spec/lib/theme_javascript_compiler_spec.rb b/spec/lib/theme_javascript_compiler_spec.rb
index 4411947..4bb011d 100644
--- a/spec/lib/theme_javascript_compiler_spec.rb
+++ b/spec/lib/theme_javascript_compiler_spec.rb
@@ -55,11 +55,11 @@ describe ThemeJavascriptCompiler do
     end
 
     it 'works with the old settings syntax' do
-      expect(render("{{themeSetting.setting_key}}")).
+      expect(render("{{themeSettings.setting_key}}")).
         to eq('setting(22:setting_key)')
 
       # Works when used inside other statements
-      expect(render("{{dummy-helper themeSetting.setting_key}}")).
+      expect(render("{{dummy-helper themeSettings.setting_key}}")).
         to eq('dummy(setting(22:setting_key))')
     end
   end
@@ -90,11 +90,11 @@ describe ThemeJavascriptCompiler do
     end
 
     it 'works with the old settings syntax' do
-      expect(statement("{{themeSetting.setting_key}}")).
+      expect(statement("{{themeSettings.setting_key}}")).
         to eq([[1, [27, "theme-setting", [22, "setting_key"], [["deprecated"], [true]]], false]])
 
       # Works when used inside other statements
-      expect(statement("{{dummy-helper themeSetting.setting_key}}")).
+      expect(statement("{{dummy-helper themeSettings.setting_key}}")).
         to eq([[1, [27, "dummy-helper", [[27, "theme-setting", [22, "setting_key"], [["deprecated"], [true]]]], nil], false]])
     end
   end

GitHub sha: 0b6be2ce

1 Like