diff --git a/app/assets/javascripts/discourse-common/addon/resolver.js b/app/assets/javascripts/discourse-common/addon/resolver.js index e07793bfb9c..5e787d63778 100644 --- a/app/assets/javascripts/discourse-common/addon/resolver.js +++ b/app/assets/javascripts/discourse-common/addon/resolver.js @@ -169,6 +169,10 @@ export function buildResolver(baseName) { return this.customResolve(parsedName) || this._super(parsedName); }, + resolveRawView(parsedName) { + return this.customResolve(parsedName) || this._super(parsedName); + }, + resolveRoute(parsedName) { if (parsedName.fullNameWithoutType === "basic") { return requirejs("discourse/routes/discourse", null, null, true) diff --git a/app/assets/javascripts/discourse/app/helpers/raw.js b/app/assets/javascripts/discourse/app/helpers/raw.js index 0ad2d6edd51..62ec07c3f19 100644 --- a/app/assets/javascripts/discourse/app/helpers/raw.js +++ b/app/assets/javascripts/discourse/app/helpers/raw.js @@ -2,20 +2,6 @@ import { helperContext, registerUnbound } from "discourse-common/lib/helpers"; import { findRawTemplate } from "discourse-common/lib/raw-templates"; import { htmlSafe } from "@ember/template"; import { RUNTIME_OPTIONS } from "discourse-common/lib/raw-handlebars-helpers"; -import { buildResolver } from "discourse-common/resolver"; - -let resolver; - -function lookupView(templateName) { - if (!resolver) { - resolver = buildResolver("discourse").create(); - } - - return resolver.customResolve({ - type: "raw-view", - fullNameWithoutType: templateName, - }); -} function renderRaw(ctx, template, templateName, params) { params = Object.assign({}, params); @@ -23,7 +9,7 @@ function renderRaw(ctx, template, templateName, params) { let context = helperContext(); if (!params.view) { - const viewClass = lookupView(templateName); + const viewClass = context.registry.resolve(`raw-view:${templateName}`); if (viewClass) { params.view = viewClass.create(params, context); diff --git a/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js b/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js index fa2ca51902a..01c1db9ec95 100644 --- a/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js +++ b/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js @@ -25,6 +25,7 @@ export function autoLoadModules(container, registry) { site: container.lookup("site:main"), session: container.lookup("session:main"), topicTrackingState: container.lookup("topic-tracking-state:main"), + registry, }; setOwner(context, container); @@ -35,5 +36,5 @@ export function autoLoadModules(container, registry) { export default { name: "auto-load-modules", - initialize: autoLoadModules, + initialize: (container) => autoLoadModules(container, container.registry), }; diff --git a/app/assets/javascripts/discourse/tests/setup-tests.js b/app/assets/javascripts/discourse/tests/setup-tests.js index 7091b471437..4c3d16b5646 100644 --- a/app/assets/javascripts/discourse/tests/setup-tests.js +++ b/app/assets/javascripts/discourse/tests/setup-tests.js @@ -293,6 +293,7 @@ function setupTestsCommon(application, container, config) { siteSettings: settings, capabilities: {}, site, + registry: app.__registry__, }); PreloadStore.reset();