turbo-rails 1.4.0 → 2.0.0.pre.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40ccdc123db34929af83c559e6bf6c65ca3027b5fd765546143f6093d34662a7
4
- data.tar.gz: 7236691e0dbf00c61fb51039212c9316b7d0fc5d03370e939c5c318b56ab70c7
3
+ metadata.gz: d64d1046010fe176342eb0dc1269ce42575b3875e8fbea14eebd282455eb28ee
4
+ data.tar.gz: 0da2bd6fdcf894118945c41d3f297c5e3638d1ff732a58b89980f033cc950ead
5
5
  SHA512:
6
- metadata.gz: e7b6bdb711d3e712ac96bd52fc6f909d2ea5beaa2ba664d10e4678792afc58bb61ecce45ccb9b745e8f3706e5221917c754c2a461caff4be864e294050aba10d
7
- data.tar.gz: a6d86dc5249f31161e4f7c3e31cfcda725b1173f0c63348c81f0cd62135688408b4b963540f80564d5eec1fb86f7601090e24c00ed5a55fa5e9c5277a18d75a4
6
+ metadata.gz: 02ce010eaa7cf96ee30e931499da76ff7beb95525c7cd1a2edd775f6aa354e8524cdbcd7bae2c8806416c6566bb7876ab3d1550fb0f29c18fe007daf2f8b0003
7
+ data.tar.gz: f31df5f93132755af3045511f998e38886240656eca467de4de278682ffd1e7c101402aab704988ab6294309d79dc8e767d72ea4d4283c26eb1ac974b7bfd2a6
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  On top of accelerating web applications, Turbo was built from the ground-up to form the foundation of hybrid native applications. Write the navigational shell of your [Android](https://github.com/hotwired/turbo-android) or [iOS](https://github.com/hotwired/turbo-ios) app using the standard platform tooling, then seamlessly fill in features from the web, following native navigation patterns. Not every mobile screen needs to be written in Swift or Kotlin to feel native. With Turbo, you spend less time wrangling JSON, waiting on app stores to approve updates, or reimplementing features you've already created in HTML.
6
6
 
7
- Turbo is a language-agnostic framework written in TypeScript, but this gem builds on top of those basics to make the integration with Rails as smooth as possible. You can deliver turbo updates via model callbacks over Action Cable, respond to controller actions with native navigation or standard redirects, and render turbo frames with helpers and layout-free responses.
7
+ Turbo is a language-agnostic framework written in JavaScript, but this gem builds on top of those basics to make the integration with Rails as smooth as possible. You can deliver turbo updates via model callbacks over Action Cable, respond to controller actions with native navigation or standard redirects, and render turbo frames with helpers and layout-free responses.
8
8
 
9
9
 
10
10
  ## Navigate with Turbo Drive
@@ -18,7 +18,7 @@ Whereas Turbolinks previously just dealt with links, Turbo can now also process
18
18
  Turbo Drive can be disabled on a per-element basis by annotating the element or any of its ancestors with `data-turbo="false"`. If you want Turbo Drive to be disabled by default, then you can adjust your import like this:
19
19
 
20
20
  ```js
21
- import { Turbo } from "@hotwired/turbo-rails"
21
+ import "@hotwired/turbo-rails"
22
22
  Turbo.session.drive = false
23
23
  ```
24
24
 
@@ -55,6 +55,37 @@ When the user will click on the `Edit this todo` link, as direct response to thi
55
55
 
56
56
  [See documentation](https://turbo.hotwired.dev/handbook/frames).
57
57
 
58
+ ### A note on custom layouts
59
+
60
+ In order to render turbo frame requests without the application layout, Turbo registers a custom [layout method](https://api.rubyonrails.org/classes/ActionView/Layouts/ClassMethods.html#method-i-layout).
61
+ If your application uses custom layout resolution, you have to make sure to return `"turbo_rails/frame"` (or `false` for TurboRails < 1.4.0) for turbo frame requests:
62
+
63
+ ```ruby
64
+ layout :custom_layout
65
+
66
+ def custom_layout
67
+ return "turbo_rails/frame" if turbo_frame_request?
68
+
69
+ # ... your custom layout logic
70
+ ```
71
+
72
+ If you are using a custom, but "static" layout,
73
+
74
+ ```ruby
75
+ layout "some_static_layout"
76
+ ```
77
+
78
+ you **have** to change it to a layout method in order to conditionally return `false` for turbo frame requests:
79
+
80
+ ```ruby
81
+ layout :custom_layout
82
+
83
+ def custom_layout
84
+ return "turbo_rails/frame" if turbo_frame_request?
85
+
86
+ "some_static_layout"
87
+ ```
88
+
58
89
  ## Come Alive with Turbo Streams
59
90
 
60
91
  Partial page updates that are **delivered asynchronously over a web socket connection** is the hallmark of modern, reactive web applications. With Turbo Streams, you can get all of that modern goodness using the existing server-side HTML you're already rendering to deliver the first page load. With a set of simple CRUD container tags, you can send HTML fragments over the web socket (or in response to direct interactions), and see the page change in response to new data. Again, **no need to construct an entirely separate API**, **no need to wrangle JSON**, **no need to reimplement the HTML construction in JavaScript**. Take the HTML you're already making, wrap it in an update tag, and, voila, your page comes alive.
@@ -96,11 +127,25 @@ import "@hotwired/turbo-rails"
96
127
 
97
128
  You can watch [the video introduction to Hotwire](https://hotwired.dev/#screencast), which focuses extensively on demonstrating Turbo in a Rails demo. Then you should familiarize yourself with [Turbo handbook](https://turbo.hotwired.dev/handbook/introduction) to understand Drive, Frames, and Streams in-depth. Finally, dive into the code documentation by starting with [`Turbo::FramesHelper`](https://github.com/hotwired/turbo-rails/blob/main/app/helpers/turbo/frames_helper.rb), [`Turbo::StreamsHelper`](https://github.com/hotwired/turbo-rails/blob/main/app/helpers/turbo/streams_helper.rb), [`Turbo::Streams::TagBuilder`](https://github.com/hotwired/turbo-rails/blob/main/app/models/turbo/streams/tag_builder.rb), and [`Turbo::Broadcastable`](https://github.com/hotwired/turbo-rails/blob/main/app/models/concerns/turbo/broadcastable.rb).
98
129
 
130
+ ### RubyDoc Documentation
131
+
132
+ For the API documentation covering this gem's classes and packages, [visit the
133
+ RubyDoc page][].
134
+
135
+ [visit the RubyDoc page](https://rubydoc.info/github/hotwired/turbo-rails/main)
99
136
 
100
137
  ## Compatibility with Rails UJS
101
138
 
102
139
  Turbo can coexist with Rails UJS, but you need to take a series of upgrade steps to make it happen. See [the upgrading guide](https://github.com/hotwired/turbo-rails/blob/main/UPGRADING.md).
103
140
 
141
+ ## Testing
142
+
143
+
144
+ The [`Turbo::TestAssertions`](./lib/turbo/test_assertions.rb) concern provides Turbo Stream test helpers that assert the presence or absence of `<turbo-stream>` elements in a rendered fragment of HTML. `Turbo::TestAssertions` are automatically included in [`ActiveSupport::TestCase`](https://edgeapi.rubyonrails.org/classes/ActiveSupport/TestCase.html) and depend on the presence of [`rails-dom-testing`](https://github.com/rails/rails-dom-testing/) assertions.
145
+
146
+ The [`Turbo::TestAssertions::IntegrationTestAssertions`](./lib/turbo/test_assertions/integration_test_assertions.rb) are built on top of `Turbo::TestAssertions`, and add support for passing a `status:` keyword. They are automatically included in [`ActionDispatch::IntegrationTest`](https://edgeguides.rubyonrails.org/testing.html#integration-testing).
147
+
148
+ The [`Turbo::Broadcastable::TestHelper`](./lib/turbo/broadcastable/test_helper.rb) concern provides Action Cable-aware test helpers that assert that `<turbo-stream>` elements were or were not broadcast over Action Cable. They are not automatically included. To use them in your tests, make sure to `include Turbo::Broadcastable::TestHelper`.
104
149
 
105
150
  ## Development
106
151