Override isHTML or locationIsVisitable?
See original GitHub issueHello!
With turbolinks I used to do this:
Turbolinks.Location.prototype.isHTML = () => true;
Is this no longer possible with Turbo?
The default extension regex often trips me up, as a PHP developer I obviously expect <turbo-frame id="messages" src="/messages.php">msg</turbo-frame>
to work.
In my case some of my URLs happen to have periods in them, which Turbo fails to load correctly (e.g. /music/prince/1989.batman) because it parses the “.batman” part as the extension.
I also tried setting data-turbo=true
, as setting data-turbo=false
forces links to not be navigable or visitable, so I figured maybe data-turbo=true
forces it in the other direction, but it seems to just give me the default behavior.
For now, the workaround I’m using is making sure my URLs end in a slash, as that seems to bypass the extension check, but it would be nice if there was some way to force Turbo to treat a particular link as navigable/visitable.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:9 (2 by maintainers)
Top GitHub Comments
I’d like to present an argument that this issue should be a little higher priority: Hotwire is being marketed as being about JS on the client and HTML on the server, not as an extension of Ruby on Rails, so it seems strange that it excludes many PHP sites, which last I checked still accounts for some 80% of server-side code on the web. Yes, not all of PHP sites out there use urls that end in
.php
, but I’m not sure why Turbo, as a client JS library, cares what my urls look like.My team would be happy to work with maintainers to find a more acceptable way to configure than
isHTML
and make a PR. I’d love to hear any response from the maintainers about this, even if it’s “wont fix” so that I know we need to fork turbo.Indeed it would be great if Turbo would support other extensions like .php as well. I know it’s now part of the Rails community, but I think it’s a great and easy way to create a SPA experience with PHP generated websites as well in a very simple way (Laravel Livewire needs Laravel).
See also my discussion topic at: https://discuss.hotwired.dev/t/how-to-make-turbo-drive-work-with-php-files-and-query-strings/2020