DEV: Update `helper.renderGlimmer` example to gjs (#28962)

This commit is contained in:
David Taylor 2024-10-04 16:04:08 +01:00 committed by GitHub
parent 8eff922ace
commit 7a46baa31c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 6 deletions

View File

@ -112,24 +112,22 @@ class DecoratorHelper {
* Returns an element containing a rendered glimmer template. For full usage instructions,
* see `widgets/render-glimmer.js`.
*
* Example usage:
* Example usage in a `.gjs` file:
*
* ```
* import { hbs } from "ember-cli-htmlbars";
*
* api.decorateCookedElement((cooked, helper) => {
* const iconName = "user-plus";
* // Generate a new element with glimmer rendered inside
* const glimmerElement = helper.renderGlimmer(
* "div.my-wrapper-class",
* hbs`<DButton @icon={{@data.param}} @translatedLabel="Hello world from Glimmer Component"/>`,
* { param: "user-plus" }
* <template><DButton @icon={{iconName}} @translatedLabel="Hello world from Glimmer Component" /></template>
* );
* cooked.appendChild(glimmerElement);
*
* // Or append to an existing element
* helper.renderGlimmer(
* cooked.querySelector(".some-container"),
* hbs`I will be appended to some-container`
* <template>I will be appended to some-container</template>
* );
* }, { onlyStream: true });
* ```