A platform for community discussion. Free, open, simple.
FIX: Correct deprecated theme settings in handlebars templates
David Taylor0b6be2cebced
diff --git a/lib/theme_javascript_compiler.rb b/lib/theme_javascript_compiler.rbindex b4290d0ae66..d5a11ca2911 100644--- a/lib/theme_javascript_compiler.rb+++ b/lib/theme_javascript_compiler.rb@@ -54,7 +54,7 @@ class ThemeJavascriptCompilerfunction 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 ThemeJavascriptCompilerHandlebars.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 syntaxlet 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].partsnode.params = []}diff --git a/spec/lib/theme_javascript_compiler_spec.rb b/spec/lib/theme_javascript_compiler_spec.rbindex 44119471ad7..4bb011d6cff 100644--- a/spec/lib/theme_javascript_compiler_spec.rb+++ b/spec/lib/theme_javascript_compiler_spec.rb@@ -55,11 +55,11 @@ describe ThemeJavascriptCompiler doendit '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))')endend@@ -90,11 +90,11 @@ describe ThemeJavascriptCompiler doendit '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]])endend