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

Templates without .html aren't rendered #80

Closed
wants to merge 1 commit into from

Conversation

dvisockas
Copy link

@dvisockas dvisockas commented Jan 11, 2021

As pointed in #22 , there is a case when a view has no .html extension (.slim instead of .html.slim)
While inspecting the request/response lifecycle in the browser I observed that the first load of the page doesn't have the turbo-stream mime type in the Accept header, however when the JS is loaded, subsequent requests have that header value present.
Somewhere in the library code, this causes the turbo:before-fetch-response event called from FetchRequest#receive JS class to be preventDefault()-ed.
If the template has a .html extension - response ceases to include turbo-stream in the Content-Type header
Currently, the PR removes .html extension from views/trays/index(.html.erb -> .erb) and adds the Accept turbo-stream header request to the test suite.
Would be happy to make the test green, however after going through all the ruby and JS codebase I cannot figure out where the hiccup might happen.

@priit
Copy link

priit commented Jan 28, 2021

I had same issue with haml templates without html prefix in file name.

I made very quick hack to study turbo-rails futher and forced content_type into text/html at application_controller.rb:

after_action { self.content_type = "text/html; charset=utf-8" if request.env["HTTP_ACCEPT"] == "text/vnd.turbo-stream.html, text/html, application/xhtml+xml" }

Now turbo_frame_tag works with GET request as expected.

@dvisockas
Copy link
Author

Seems to be fixed by #52

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.

None yet

2 participants