mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 11:15:05 +08:00
FIX: Correct deprecated theme settings in handlebars templates
Was overriding the incorrect `themeSetting.blah` syntax, instead of `themeSettings.blah`
This commit is contained in:
parent
b9b5527c63
commit
0b6be2cebc
|
@ -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 = []
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user