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/app/helpers/custom-html.js
Robin Ward 01929e3505 DEV: Move preload-store to discourse/lib/preload-store
It's only used inside Discourse so it needn't be its own module
2020-05-06 15:28:06 -04:00

26 lines
596 B
JavaScript

import PreloadStore from "discourse/lib/preload-store";
import { htmlSafe } from "@ember/template";
let _customizations = {};
export function getCustomHTML(key) {
const c = _customizations[key];
if (c) {
return htmlSafe(c);
}
const html = PreloadStore.get("customHTML");
if (html && html[key] && html[key].length) {
return htmlSafe(html[key]);
}
}
export function clearHTMLCache() {
_customizations = {};
}
// Set a fragment of HTML by key. It can then be looked up with `getCustomHTML(key)`.
export function setCustomHTML(key, html) {
_customizations[key] = html;
}