Skip to content

Commit

Permalink
Merge pull request #481 from cyupa/master
Browse files Browse the repository at this point in the history
Extend documentation for using Stimulus within sidecar directories
  • Loading branch information
joelhawksley authored Sep 14, 2020
2 parents f58e7cd + f041a4b commit f0b1141
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master

* Extend documentation for using Stimulus within sidecar directories.

*Ciprian Redinciuc*

* Subclassed components inherit templates from parent.

*Blake Williams*
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,29 @@ application.load(

This enables the creation of files such as `app/components/widget_controller.js`, where the controller identifier matches the `data-controller` attribute in the component's HTML template.

When placing a Stimulus controller inside a sidecar directory, be aware that when referencing the controller [each forward slash in a namespaced controller file’s path becomes two dashes in its identifier](
https://stimulusjs.org/handbook/installing#controller-filenames-map-to-identifiers):

```console
app/components
├── ...
├── example
| ├── component.rb
| ├── component.css
| ├── component.html.erb
| └── component_controller.js
├── ...
```

`component_controller.js`'s Stimulus identifier becomes: `example--component`:

```erb
<div data-controller="example--component">
<input type="text">
<button data-action="click->example--component#greet">Greet</button>
</div>
```

## Frequently Asked Questions

### Can I use other templating languages besides ERB?
Expand Down

0 comments on commit f0b1141

Please sign in to comment.