https://github.com/sbsoftware/crumble-stimulus
Seamless integration of stimulus.cr into crumble
https://github.com/sbsoftware/crumble-stimulus
Last synced: 10 months ago
JSON representation
Seamless integration of stimulus.cr into crumble
- Host: GitHub
- URL: https://github.com/sbsoftware/crumble-stimulus
- Owner: sbsoftware
- License: mit
- Created: 2023-12-01T21:24:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-18T20:01:24.000Z (about 1 year ago)
- Last Synced: 2025-02-18T21:21:55.024Z (about 1 year ago)
- Language: Crystal
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# crumble-stimulus
Seamless integration of [stimulus.cr](https://github.com/sbsoftware/stimulus.cr) into [crumble](https://github.com/sbsoftware/crumble), providing a JS module that includes all your `Stimulus::Controller`s that is automatically added to your layout template.
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
crumble-stimulus:
github: sbsoftware/crumble-stimulus
```
2. Run `shards install`
## Usage
```crystal
# make sure this comes before you require any controllers you want to include,
# otherwise they'll be missing
require "crumble-stimulus"
# or wherever your Stimulus controllers are
require "./stimulus_controllers/*"
```
The `Crumble::StimulusControllers` script is automatically added to any template inheriting from the generic `ToHtml::Layout`.
### Custom Layout
If you don't use a layout based on `ToHtml::Layout`, you'll have to include the `Crumble::StimulusControllers` script manually:
```crystal
html do
head do
# [...]
Crumble::StimulusControllers
# [...]
end
end
```