From 0b6be2cebcedc908a5e4377dc435cb74a3f6519e Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 18 Jan 2019 15:39:28 +0000 Subject: [PATCH] FIX: Correct deprecated theme settings in handlebars templates Was overriding the incorrect `themeSetting.blah` syntax, instead of `themeSettings.blah` --- lib/theme_javascript_compiler.rb | 8 ++++---- spec/lib/theme_javascript_compiler_spec.rb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/theme_javascript_compiler.rb b/lib/theme_javascript_compiler.rb index b4290d0ae6..d5a11ca291 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 44119471ad..4bb011d6cf 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