You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-5
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Custom Elements with Rails
2
2
3
-
This gem provides a small js-helper, installation and generators to use custom elements in conjunction with `importmap-rails`.
3
+
This gem provides a small js-helper, installation and generators to use custom elements in conjunction with `importmap-rails` gem.
4
4
5
5
## Usage
6
6
@@ -23,7 +23,7 @@ Run the initial setup:
23
23
$ rails custom_elements:install
24
24
```
25
25
26
-
This will setup and add the following files:
26
+
This will setup and edit add the following files:
27
27
28
28
```
29
29
app/javascript
@@ -37,16 +37,17 @@ You can now add the `<app-hello>` custom element in your HTML. No build step nee
37
37
38
38
## How it works
39
39
40
-
`eagerDefineCustomElementsFrom("custom_elements", { prefix: "app" })` will parse the JSON-importmap rendered by the `importmap-rails` gem and register custom elements with `customElements.define(...)` to the browser's custom element registry.
40
+
`eagerDefineCustomElementsFrom` will parse the JSON-importmap rendered by the `importmap-rails` gem.
41
+
It registers custom elements with `customElements.define(...)` to the browser's custom element registry based on the filename automatically.
41
42
42
43
```
43
44
custom_elements/hello_element.js // will register <app-hello>
44
45
```
45
46
46
-
Your `_element.js` files have to `export default` custom elements for this to work.
47
+
Your `*_element.js` files have to `export default` custom elements for this to work properly.
47
48
48
49
> [!WARNING]
49
-
> Only single word elements are support currently.
50
+
> Only single word elements are supported currently. See https://github.com/codergeek121/custom_elements-rails/issues/1
0 commit comments