This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/helpers/theme-setting-injector.es6

21 lines
540 B
JavaScript

// A small helper to inject theme settings into
// context objects of handlebars templates used
// in themes
import { registerHelper } from 'discourse-common/lib/helpers';
function inject(context, key, value) {
if (typeof value === "string") {
value = value.replace(/\\u0022/g, '"');
}
if (!context.get("themeSettings")) {
context.set("themeSettings", {});
}
context.set(`themeSettings.${key}`, value);
}
registerHelper('theme-setting-injector', function(arr, hash) {
inject(hash.context, hash.key, hash.value);
});