discourse/app/assets/javascripts
David Taylor af30536690
DEV: Allow PluginOutlets to 'wrap' a core implementation (#23110)
Our existing PluginOutlet system allows theme/plugin developers to easily insert new content into Discourse.

Another common requirement is to **replace** existing content in Discourse. Previously this could be achieved either using template overrides, or by introducing new content via a PluginOutlet and then hiding the old implementation with CSS. Neither of these patterns are ideal from a maintainability or performance standpoint.

This commit introduces a new mode for PluginOutlets. They can now be used to 'wrap' blocks of content in core. If a plugin/theme registers a connector for the outlet, then it will be rendered **instead of** the core implementation. If needed, outlets can use `{{yield}}` to render the core implementation inside their own implementation (e.g. to add a wrapper element).

In this 'wrapper' mode, only one connector can be registered for each outlet. If more than one is registered, only one will be used, and an error will be printed to the console.

To introduce a new PluginOutlet wrapper, this kind of thing can be added to a core template:

```hbs
<PluginOutlet @name="site-logo" @defaultGlimmer={{true}} @outletArgs={{hash title=title}}>
  <h1>This is the default core implementation: {{title}}</h1>
</PluginOutlet>
```

A plugin/theme can then register a connector for the `site-logo` outlet:

```hbs
{{! connectors/site-logo/my-site-logo-override.hbs }}
<h2>This is the plugin implementation: {{@outletArgs.title}}</h2>
```

Care should be taken when introducing new wrapper PluginOutlets. We need to ensure that

1) They are properly sized. In general it's preferable for each outlet to wrap a small amount of core code, so that plugin/themes only need to re-implement what they want to change

2) The `@outletArgs` are carefully chosen. It may be tempting to pass through lots of core implementation into the outletArgs (or worse, use `this` to pass a reference to the wrapping component/controller). Doing this will significantly increase the API surface area, and make it hard to refactor core. Instead, we should aim to keep `@outletArgs` to a minimum, even if that means re-implementing some very simple things in themes/plugins.
2023-09-25 14:56:06 +01:00
..
admin Build(deps-dev): Bump the babel group (#23622) 2023-09-25 10:21:55 +02:00
bootstrap-json DEV: Make index.html a valid html (#23289) 2023-08-28 14:44:38 +02:00
confirm-new-email DEV: Add error message styling (#21225) 2023-04-25 08:40:18 -04:00
deprecation-silencer DEV: move deprecation silencer to a shared package (#22668) 2023-07-18 19:07:20 +01:00
dialog-holder DEV: Update DButton uses (#23333) 2023-08-31 11:49:35 +02:00
discourse DEV: Allow PluginOutlets to 'wrap' a core implementation (#23110) 2023-09-25 14:56:06 +01:00
discourse-common Build(deps-dev): Bump the babel group (#23622) 2023-09-25 10:21:55 +02:00
discourse-hbr Build(deps-dev): Bump the babel group (#23622) 2023-09-25 10:21:55 +02:00
discourse-plugins Build(deps-dev): Bump the babel group (#23622) 2023-09-25 10:21:55 +02:00
discourse-widget-hbs Build(deps-dev): Bump the babel group (#23622) 2023-09-25 10:21:55 +02:00
docs
ember-addons
ember-cli-progress-ci
ember-production-deprecations DEV: Clean up package.json files (#22349) 2023-06-30 13:01:45 +02:00
locales DEV: Raise an error in test env when I18n interpolate argument is missing (#23527) 2023-09-13 10:53:48 +08:00
patches DEV: introduce Embroider behind a flag, and start testing in CI (#23005) 2023-09-07 13:15:43 +01:00
pretty-text Build(deps-dev): Bump the babel group (#23622) 2023-09-25 10:21:55 +02:00
select-kit Build(deps-dev): Bump the babel group (#23622) 2023-09-25 10:21:55 +02:00
truth-helpers Build(deps-dev): Bump the babel group (#23622) 2023-09-25 10:21:55 +02:00
wizard Build(deps-dev): Bump the babel group (#23622) 2023-09-25 10:21:55 +02:00
.licensee.json DEV: Update sub-dependencies (#22325) 2023-06-29 17:08:33 +02:00
.npmrc
handlebars-shim.js
js-processor.js DEV: Enable ember-this-fallback in themes (#23384) 2023-09-05 11:16:12 +02:00
package.json DEV: Automatically retry patch-package on failure (#23583) 2023-09-14 12:25:06 +01:00
polyfills.js
run-patch-package DEV: Automatically retry patch-package on failure (#23583) 2023-09-14 12:25:06 +01:00
service-worker.js.erb FIX: Ensure service-worker cache is cleaned correctly (#23204) 2023-08-23 13:58:32 +01:00
yarn.lock DEV: Install ember-route-template (#23532) 2023-09-25 14:14:24 +01:00