-
Notifications
You must be signed in to change notification settings - Fork 330
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
Separate turbo meta tag generation from provides #542
Conversation
Hey @bradgessler, Thanks for your work here. I don't love the breaking API change here. Furthermore, a nice thing with the current approach is that you can use helpers like Maybe an alternative could be to just provide |
The changes shouldn't be breaking any APIs or change the behavior of what's already there, with the exception of providing content for This PR only adds to the API with helpers like |
That's what I mean by breaking change. It will break existing usages if they don't change the code after updating. I'd just leave the |
08bf75d
to
0c7fabb
Compare
Ok I switched the I disagree about readability of I do think there's a better way to handle all of this because, as it stands, if a developer calls any of these helpers multiple times, it will keep appending the meta tag to the |
0c7fabb
to
823b14f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the changes @bradgessler. I think the turbo_meta_tags
helper method makes sense to just encapsulate yield :head
(without additional options). But I in the PR you removed it completely, despite of it being referred to. I think that's an oversight?
I think it's a good idea to keep it, but without options. So it's just a replacement for yield :head
you can use, but if your app is doing yield :head
it still works.
We need to review the code docs a bit here, but that was also pending for the new morphing helpers, so we'll address that separately.
Oh I misunderstood ... I thought you requested it be completely removed. Yes! I will add it back without accepting options. |
This makes it possible to use the meta tag helpers from outside Rails rendering, such as an app built entirely from Phlex components. The `turbo_meta_tags` method was added to minimize confusion over the seemingly random `content_for :head` that has been observed in early Turbo 8 betas. This is a thin wrapper around `content_for :head`.
823b14f
to
d966ddf
Compare
Ok I pushed up the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bradgessler
I'm not a fan of Also, this PR is missing documentation for the new tag methods. And the documentation around "These helpers require a +yield :head+ provision in the layout" is now also outdated since we have the new _tag variants. Need to properly describe the difference, the point about using the tag-less helpers inside templates that live separately from the layout, etc. I think as it stands here, we've made things somewhat worse than they were. So let's get things back on track with proper documentation. |
@bradgessler could you create a PR reverting the What I don't love about |
I'd rather push |
Actually something else we could do is build a fail safe. If you add content to a variable that's then never yielded, we'd throw a warning. But might be too much overhead/complexity to track that for something so relatively uncommon. |
Removes the requirement to have a
content_for :head
tag in the head of the Rails application. Instead the developer just adds theturbo_meta_tags(method: :morph, scroll: :preserve)
to the top of their pages and it will setup theyield :turbo_head
block that the helpers provide viaprovide :turbo_head
.That means developers can do this:
Instead of this:
And prevent confusion like this: https://www.reddit.com/r/rails/comments/186z9lu/comment/kd60oq4/?utm_source=reddit&utm_medium=web2x&context=3
This also makes it possible to use the meta tag helpers from outside Rails rendering, such as an app built entirely from Phlex components.
If there's general interest in merging PRs that improve the developer experience, I could make additional improvements that make configuring Turbo pages easier from the controller in addition to the view.