diff --git a/app/assets/javascripts/discourse/helpers/raw-plugin-outlet.js.es6 b/app/assets/javascripts/discourse/helpers/raw-plugin-outlet.js.es6 index ccea57e1e22..aa8657464a9 100644 --- a/app/assets/javascripts/discourse/helpers/raw-plugin-outlet.js.es6 +++ b/app/assets/javascripts/discourse/helpers/raw-plugin-outlet.js.es6 @@ -1,7 +1,7 @@ -import { connectorsFor } from 'discourse/lib/plugin-connectors'; +import { rawConnectorsFor } from 'discourse/lib/plugin-connectors'; Handlebars.registerHelper('raw-plugin-outlet', function(args) { - const connectors = connectorsFor(args.hash.name); + const connectors = rawConnectorsFor(args.hash.name); if (connectors.length) { const output = connectors.map(c => c.template({context: this})); return new Handlebars.SafeString(output.join("")); diff --git a/app/assets/javascripts/discourse/lib/plugin-connectors.js.es6 b/app/assets/javascripts/discourse/lib/plugin-connectors.js.es6 index 73ed1d9678d..61cdbab2554 100644 --- a/app/assets/javascripts/discourse/lib/plugin-connectors.js.es6 +++ b/app/assets/javascripts/discourse/lib/plugin-connectors.js.es6 @@ -1,4 +1,5 @@ let _connectorCache; +let _rawConnectorCache; let _extraConnectorClasses = {}; let _classPaths; @@ -42,6 +43,7 @@ function findOutlets(collection, callback) { export function clearCache() { _connectorCache = null; + _rawConnectorCache = null; } function findClass(outletName, uniqueName) { @@ -63,7 +65,7 @@ function findClass(outletName, uniqueName) { function buildConnectorCache() { _connectorCache = {}; - findOutlets(Ember.TEMPLATES, function(outletName, resource, uniqueName) { + findOutlets(Ember.TEMPLATES, (outletName, resource, uniqueName) => { _connectorCache[outletName] = _connectorCache[outletName] || []; _connectorCache[outletName].push({ @@ -75,7 +77,22 @@ function buildConnectorCache() { }); } +function buildRawConnectorCache() { + _rawConnectorCache = {}; + findOutlets(Discourse.RAW_TEMPLATES, (outletName, resource) => { + _rawConnectorCache[outletName] = _rawConnectorCache[outletName] || []; + _rawConnectorCache[outletName].push({ + template: Discourse.RAW_TEMPLATES[resource] + }); + }); +} + export function connectorsFor(outletName) { if (!_connectorCache) { buildConnectorCache(); } return _connectorCache[outletName] || []; } + +export function rawConnectorsFor(outletName) { + if (!_rawConnectorCache) { buildRawConnectorCache(); } + return _rawConnectorCache[outletName] || []; +} diff --git a/test/javascripts/acceptance/raw-plugin-outlet-test.js.es6 b/test/javascripts/acceptance/raw-plugin-outlet-test.js.es6 new file mode 100644 index 00000000000..3611bf1cddd --- /dev/null +++ b/test/javascripts/acceptance/raw-plugin-outlet-test.js.es6 @@ -0,0 +1,23 @@ +import { acceptance } from "helpers/qunit-helpers"; + +const CONNECTOR = 'javascripts/raw-test/connectors/topic-list-tags/lala'; +acceptance("Raw Plugin Outlet", { + setup() { + Discourse.RAW_TEMPLATES[CONNECTOR] = Handlebars.compile( + `{{context.topic.id}}` + ); + }, + + teardown() { + delete Discourse.RAW_TEMPLATES[CONNECTOR]; + } +}); + +test("Renders the raw plugin outlet", assert => { + visit("/"); + andThen(() => { + assert.ok(find('.topic-lala').length > 0, 'it renders the outlet'); + assert.equal(find('.topic-lala:eq(0)').text(), '11557', 'it has the topic id'); + }); +}); +