Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend ActionDispatch::Request #250

Conversation

seanpdoyle
Copy link
Contributor

Implements Request#turbo_frame? predicate along with the
Request#turbo_frame accessor. Both read from the Turbo-Frame:
header.

Mark variant as turbo_frame when header present

Closes #229

Mark the request's variant as :turbo_frame whenever the
Turbo-Frame: header is present in the request. Also adds documentation
to describe how to achieve the previously built-in layout optimizations.

Implements `Request#turbo_frame?` predicate along with the
`Request#turbo_frame` accessor. Both read from the `Turbo-Frame:`
header.

Mark variant as `turbo_frame` when header present
---

Closes hotwired#229

Mark the request's [variant][] as `:turbo_frame` whenever the
`Turbo-Frame:` header is present in the request. Also adds documentation
to describe how to achieve the previously built-in layout optimizations.

[variant]: https://guides.rubyonrails.org/4_1_release_notes.html#action-pack-variants
@dhh
Copy link
Member

dhh commented Oct 13, 2021

I don't love the idea of using variants for turbo frames. We did variants originally to provide different types of HTML responses for different platforms, like a native iOS app. Where what you want to send is something substantially different because of the constraints of the platform. I don't think that applies here.

I'm fine with having a way to detect turbo frame requests as a conditional, but I think that's as far as it should go. This should be the exception. If you're branching all your responses for frames vs not, something isn't right, and we should investigate those pressures in a different way.

Also don't love the idea of Request itself getting extended with this predicate. That's too low level. The integration we're doing for Turbo is at the controller level. I'd rather just keep things there.

@dhh dhh closed this Oct 13, 2021
@WriterZephos
Copy link

@dhh I am confused about how to make a controller action respond appropriately to both internal requests that should just replace turbo-frames and requests coming from outside. It seems that layouts get rendered by default, but you would want to turn them off in the former case, and there is no way of doing that conditionally so that you don't mess up the latter case.

Is there a detail or a pattern I am missing here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Turbo-frame request variant
3 participants