diff --git a/app/assets/javascripts/discourse/helpers/theme-setting-injector.es6 b/app/assets/javascripts/discourse/helpers/theme-setting-injector.es6 index 4a0d5916efd..a9da2e70d31 100644 --- a/app/assets/javascripts/discourse/helpers/theme-setting-injector.es6 +++ b/app/assets/javascripts/discourse/helpers/theme-setting-injector.es6 @@ -4,10 +4,7 @@ import { registerHelper } from 'discourse-common/lib/helpers'; -registerHelper('theme-setting-injector', function(arr, hash) { - const context = hash.context; - let value = hash.value; - +function inject(context, key, value) { if (typeof value === "string") { value = value.replace(/\\u0022/g, '"'); } @@ -15,5 +12,13 @@ registerHelper('theme-setting-injector', function(arr, hash) { if (!context.get("themeSettings")) { context.set("themeSettings", {}); } - context.set(`themeSettings.${hash.key}`, value); + context.set(`themeSettings.${key}`, value); +} + +registerHelper('theme-setting-injector', function(arr, hash) { + inject(hash.context, hash.key, hash.value); +}); + +Handlebars.registerHelper('theme-setting-injector', function(hash) { + inject(hash.data.root, hash.hash.key, hash.hash.value); }); diff --git a/spec/models/theme_field_spec.rb b/spec/models/theme_field_spec.rb index 0f9677780bf..8ec0a5249b1 100644 --- a/spec/models/theme_field_spec.rb +++ b/spec/models/theme_field_spec.rb @@ -21,6 +21,22 @@ HTML expect(field.error).to eq(nil) end + it "allows us to use theme settings in handlebars templates" do + html = < +