Skip to content

Commit 558471f

Browse files
committed
Add template-registry
1 parent 97a21e2 commit 558471f

File tree

2 files changed

+49
-14
lines changed

2 files changed

+49
-14
lines changed

ember-element-helper/README.md

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
ember-element-helper
2-
==============================================================================
1+
# ember-element-helper
32

43
[![Build Status](https://github.com/tildeio/ember-element-helper/actions/workflows/ci.yml/badge.svg)](https://github.com/tildeio/ember-element-helper/actions/workflows/ci.yml)
54

@@ -18,15 +17,13 @@ this addon as a true polyfill for the feature, allowing the feature to be used
1817
on older Ember.js versions and be completely inert on newer versions where the
1918
official implementation is available.
2019

21-
Compatibility
22-
------------------------------------------------------------------------------
20+
## Compatibility
2321

2422
* Ember.js v3.24 or above
2523
* Ember CLI v3.24 or above
2624
* Node.js v12 or above
2725

28-
Limitations
29-
------------------------------------------------------------------------------
26+
## Limitations
3027

3128
This implementation has the following known limitations:
3229

@@ -52,15 +49,13 @@ This implementation has the following known limitations:
5249
which is first available on Ember 3.11. This is an Ember.js limitation,
5350
unrelated to this addon.
5451

55-
Installation
56-
------------------------------------------------------------------------------
52+
## Installation
5753

5854
```
5955
ember install ember-element-helper
6056
```
6157

62-
Usage
63-
------------------------------------------------------------------------------
58+
## Usage
6459

6560
```hbs
6661
{{#let (element this.tagName) as |Tag|}}
@@ -85,12 +80,47 @@ that accepts "contextual components" as arguments:
8580
<@tag class="my-tag">hello world!</@tag>
8681
```
8782

88-
Contributing
89-
------------------------------------------------------------------------------
83+
### Single File Components
84+
85+
Using the `(element)` helper with [first class component
86+
templates](http://emberjs.github.io/rfcs/0779-first-class-component-templates.html):
87+
88+
```gjs
89+
import { element } from 'ember-element-helper';
90+
91+
<template>
92+
{{#let (element @tagName) as |Tag|}}
93+
<Tag class="my-tag">hello world!</Tag>
94+
{{/let}}
95+
</template>
96+
```
97+
98+
### Glint Usage in Classic Mode
99+
100+
In order to use a typed `(element)` helper in classic mode, you need to import
101+
the addon's glint template registry and extend your app's registry declaration
102+
as described in the [Using
103+
Addons](https://typed-ember.gitbook.io/glint/using-glint/ember/using-addons#using-glint-enabled-addons)
104+
documentation:
105+
106+
```ts
107+
import '@glint/environment-ember-loose';
108+
import type EmberElementHelperRegistry from 'ember-element-helper/template-registry';
109+
110+
declare module '@glint/environment-ember-loose/registry' {
111+
export default interface Registry extends EmberElementHelperRegistry, /* other addon registries */ {
112+
// local entries
113+
}
114+
}
115+
```
116+
117+
> **Note:** Glint itself is still under active development, and as such breaking changes might occur.
118+
> Therefore, Glint support by this addon is also considered experimental, and not covered by our SemVer contract!
119+
120+
## Contributing
90121

91122
See the [Contributing](CONTRIBUTING.md) guide for details.
92123

93-
License
94-
------------------------------------------------------------------------------
124+
## License
95125

96126
This project is licensed under the [MIT License](LICENSE.md).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type ElementHelper from './helpers/element';
2+
3+
export default interface EmberElementHelperRegistry {
4+
element: typeof ElementHelper;
5+
}

0 commit comments

Comments
 (0)