Cannot get turbo_frame_tag to print #217
|
Hey there - great gem. Plex gave us a speed-up of at least 60% compared to calling hundreds of partial renders (before you jump in: I know, it shouldn't be done that way in the first place). A problem I'm facing now: print a module Views
class TableCell < ApplicationView
delegate :turbo_frame_tag, to: :helpers
def template
# super weird. it should work: https://github.com/hotwired/turbo-rails/blob/main/app/helpers/turbo/frames_helper.rb
turbo_frame_tag id: "foo" do
p "content"
end
end
endit prints the content, but not the tag. I guess that's due to the turbo_frame_tag itself - but maybe there's a workaround I'm not seeing yet? |
Replies: 2 comments 3 replies
|
Hey @tillcarlos, in your We should address this more directly in the framework and documentation, as it's really confusing as it is. The problem with the Rails tag helpers is they return a String of the HTML, they don't append directly to the output buffer. That makes it quite tricky to integrate with them, since we have no way to capture the return value of multiple statements unless they're passed to a method. By way of example, you could probably get |
Why not? I use Tailwind and make a new Phlex::View practically every time I would have otherwise made a semantic CSS class. |
Hey @tillcarlos, in your
ApplicationView, you can register a custom element withregister_element :turbo_frame. Then just use theturbo_frameelement method rather than theturbo_frame_taghelper.We should address this more directly in the framework and documentation, as it's really confusing as it is. The problem with the Rails tag helpers is they return a String of the HTML, they don't append directly to the output buffer. That makes it quite tricky to integrate with them, since we have no way to capture the return value of multiple statements unless they're passed to a method. By way of example, you could probably get
raw turbo_frame_tagto work.