FIX: Core templates should never overwrite theme/plugins (#12988)

FIX: Core templates should never overwrite theme/plugins (#12988)

This happened in Ember CLI due to a different script load order.

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 b39c9ec..2b88dfc 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 659f924..ff9b87a 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;"
   );
 };

GitHub sha: 225c0d2d

This commit appears in #12988 which was approved by pmusaraj. It was merged by eviltrout.