From 225c0d2d96625cbe50f5c50471a11281457fa149 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 7 May 2021 14:41:06 -0400 Subject: [PATCH] FIX: Core templates should never overwrite theme/plugins (#12988) This happened in Ember CLI due to a different script load order. --- .../javascripts/discourse-common/addon/lib/raw-templates.js | 6 +++++- .../javascripts/discourse-hbr/raw-handlebars-compiler.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse-common/addon/lib/raw-templates.js b/app/assets/javascripts/discourse-common/addon/lib/raw-templates.js index b39c9eca74f..2b88dfc82b8 100644 --- a/app/assets/javascripts/discourse-common/addon/lib/raw-templates.js +++ b/app/assets/javascripts/discourse-common/addon/lib/raw-templates.js @@ -2,7 +2,11 @@ import { getResolverOption } from "discourse-common/resolver"; export const __DISCOURSE_RAW_TEMPLATES = {}; -export function addRawTemplate(name, template) { +export function addRawTemplate(name, template, opts = {}) { + // Core templates should never overwrite themes / plugins + if (opts.core && __DISCOURSE_RAW_TEMPLATES[name]) { + return; + } __DISCOURSE_RAW_TEMPLATES[name] = template; } diff --git a/app/assets/javascripts/discourse-hbr/raw-handlebars-compiler.js b/app/assets/javascripts/discourse-hbr/raw-handlebars-compiler.js index 659f9241149..ff9b87a04ad 100644 --- a/app/assets/javascripts/discourse-hbr/raw-handlebars-compiler.js +++ b/app/assets/javascripts/discourse-hbr/raw-handlebars-compiler.js @@ -143,7 +143,7 @@ TemplateCompiler.prototype.processString = function (string, relativePath) { ");\n\n" + 'addRawTemplate("' + filename + - '", template);\n' + + '", template, { core: true });\n' + "export default template;" ); };