-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Change behavior of render "foo" to render a string instead of a Rails template #149
Conversation
1f5917e
to
5b00f07
Compare
32e6aee
to
69c64f8
Compare
Turns out Given this Erb template:
The first one will work, but the latter will throw this error:
|
New approach, which I think could eliminate a lot of the overrides. render(rails("fizz") { "buzz" }) The # frozen_string_literal: true
# @api private
module Phlex::Rails
class Rendition
attr_reader :args, :kwargs, :block
def initialize(*args, **kwargs, &block)
@args = args
@kwargs = kwargs
@block = block
end
end
end Which is intercepted by the when Phlex::Rails::Rendition
captured_block = -> { capture(&renderable.block) } if renderable.block
@_context.target << @_view_context.render(*renderable.args, **renderable.kwargs, &captured_block) I would propose moving this into an adapter, which would be included via the kitchen sink, but at least for all-Phlex apps the Rails renderer would never be invoked. |
I opened a bug at rails/rails#51015. If Rails decides this is a bug and fixes it, we should be set. If they don't then we'll have to figure out how to render from Phlex in a manner that doesn't obstruct the "fidelity" of rendering in Rails. |
Had a conversation about the Rails issue here. https://discord.com/channels/849034466856665118/974005005768069211/1218911072522600481 |
@bradgessler any thoughts on what we can do about this for 2.0? 🤔 |
Yeah we could either take the approach above where we wrap Rails rendering calls in a class via Another option is Phlex assumes Another option is we could have a I think we should rule out patching Rails since (1) they don't seem interested and (2) getting patches through for stuff like this has historically been a 🥙 for me. |
Agh, this is such a tricky issue. None of those options feel quite right, but we have to come up with something. 🤔 |
From Issue #137, this PR makes it such that:
renders a String instead of the rails partial
foo
. Rendering a partial will be changed to:This will be a breaking change for Phlex 1.x and ultimately require a path to Phlex 2.x. As such, I'm going to have an
Overrides::Version1
andOverrides::Verrsion2
module that get included depending on the setting specified. This will let people upgraded in 1.x to 2.x. When 2.x ships I'll remove 1.x and any updates will break.