Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcoroth/turbo-ruby
Turbo helpers without the requirement for Rails
https://github.com/marcoroth/turbo-ruby
hotwire phlex rails turbo
Last synced: 10 days ago
JSON representation
Turbo helpers without the requirement for Rails
- Host: GitHub
- URL: https://github.com/marcoroth/turbo-ruby
- Owner: marcoroth
- License: mit
- Created: 2023-01-06T15:40:11.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-10T11:48:04.000Z (almost 2 years ago)
- Last Synced: 2024-10-23T14:00:29.211Z (19 days ago)
- Topics: hotwire, phlex, rails, turbo
- Language: Ruby
- Homepage:
- Size: 32.2 KB
- Stars: 45
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-hotwire - turbo-ruby - Ruby integration for Turbo. (**Awesome Hotwire** [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome) / Turbo)
- awesome-hotwire - turbo-ruby - Ruby integration for Turbo. (**Awesome Hotwire** [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome) / Turbo)
README
# Turbo::Ruby
## Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add turbo-ruby
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install turbo-ruby
## Note: Usage in Rails
In order to use `turbo-ruby` in Rails with the Rails `render` method you have to install the `phlex-rails` gem in your app.
### Regular Element
```ruby
# Ruby
Turbo::Elements::TurboStream.new(action: "console_log", message: "Hello World").to_html
``````html+erb
<%= render Turbo::Elements::TurboStream.new(action: "console_log", message: "Hello World") %>
```### Blocks
```ruby
# Ruby
Turbo::Elements::TurboStream.new(action: "morph", target: "post_1") do
%()
Post 1
end.to_html
``````html+erb
<%= render Turbo::Elements::TurboStream.new(action: "morph", target: "post_1") do %>
Post 1
<% end %>
```### Partials (Rails only)
```html+erb
<%= render Turbo::Elements::TurboStream.new(action: "morph", target: "post_1", view_context: self, partial: "posts/post", locals: { post: @post } %>
```## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/marcoroth/turbo-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/marcoroth/turbo-ruby/blob/main/CODE_OF_CONDUCT.md).
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
Everyone interacting in the Turbo::Ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/marcoroth/turbo-ruby/blob/main/CODE_OF_CONDUCT.md).