Skip to content
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

Require long-form partial rendering #223

Merged
merged 1 commit into from
Sep 6, 2024
Merged

Conversation

joeldrapper
Copy link
Collaborator

@joeldrapper joeldrapper commented Sep 6, 2024

Closes #137

In order to render a partial, you must pass it as the partial: keyword argument.

renderable = args[0]
partial = kwargs.delete(:partial)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this move down to the when nil clause?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just caught that myself. Pushed up a change.

@bradgessler
Copy link
Contributor

Yay! This cleans up a bunch of weird things I had to do in Rails to have Phlex render a string value.

@joeldrapper joeldrapper merged commit 4ed04e8 into main Sep 6, 2024
1 of 5 checks passed
@joeldrapper joeldrapper deleted the explicit-partial-rendering branch September 6, 2024 22:55
@julianrubisch
Copy link

I'm late to the party here, but I just noticed that it's needed to be called like this:

render(partial: "form", post: @post)

which, AFAIK, wouldn't work in ActionView, it would require the locals keyword:

render(partial: "form", locals: { post: @post })

is it worth noting this inconsistency somewhere?

@joeldrapper
Copy link
Collaborator Author

Agh, that's annoying. I wonder if it would be better for us to support this instead

render partial("foo"), ...

@julianrubisch
Copy link

That would be more consistent, but I think it just boils down to adding it to the docs

@joeldrapper
Copy link
Collaborator Author

Thanks for catching this. We should get it right before the 2.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

render "foo" tries to render the Rails "foo" view instead of a string
4 participants