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
end it 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? |
Beta Was this translation helpful? Give feedback.
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 |
Beta Was this translation helpful? Give feedback.
-
Why not? I use Tailwind and make a new Phlex::View practically every time I would have otherwise made a semantic CSS class. |
Beta Was this translation helpful? Give feedback.
Hey @tillcarlos, in your
ApplicationView
, you can register a custom element withregister_element :turbo_frame
. Then just use theturbo_frame
element method rather than theturbo_frame_tag
helper.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_tag
to work.