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/components/plugin-outlet.js
Jarek Radosz 99b2cfe26e
DEV: Disallow Ember global usage (#16147)
…and sprinkle `// eslint-disable-next-line no-undef` throughout the code where is unavoidable for now
2022-03-09 17:54:07 +01:00

55 lines
1.3 KiB
JavaScript

import Component from "@ember/component";
import {
buildArgsWithDeprecations,
renderedConnectorsFor,
} from "discourse/lib/plugin-connectors";
/**
A plugin outlet is an extension point for templates where other templates can
be inserted by plugins.
## Usage
If your handlebars template has:
```handlebars
{{plugin-outlet name="evil-trout"}}
```
Then any handlebars files you create in the `connectors/evil-trout` directory
will automatically be appended. For example:
plugins/hello/assets/javascripts/discourse/templates/connectors/evil-trout/hello.hbs
With the contents:
```handlebars
<b>Hello World</b>
```
Will insert <b>Hello World</b> at that point in the template.
## Disabling
If a plugin returns a disabled status, the outlets will not be wired up for it.
The list of disabled plugins is returned via the `Site` singleton.
**/
export default Component.extend({
tagName: "",
connectorTagName: "",
connectors: null,
init() {
this._super(...arguments);
const name = this.name;
if (name) {
const args = buildArgsWithDeprecations(
this.args || {},
this.deprecatedArgs || {}
);
this.set("connectors", renderedConnectorsFor(name, args, this));
}
},
});