-
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
Add optional method to TagBuilder for morph #665
Add optional method to TagBuilder for morph #665
Conversation
836842c
to
6c9feb3
Compare
@@ -77,8 +77,8 @@ def remove_all(targets) | |||
# <%= turbo_stream.replace "clearance_5" do %> | |||
# <div id='clearance_5'>Replace the dom target identified by clearance_5</div> | |||
# <% end %> | |||
def replace(target, content = nil, **rendering, &block) | |||
action :replace, target, content, **rendering, &block | |||
def replace(target, content = nil, method = nil, **rendering, &block) |
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.
maybe this should be a keyword argument instead of a positional argument so one can pass rendering options without specifying the method?
btw, thanks for opening this PR 🙌
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.
DONE
template = render_template(target, content, allow_inferred_rendering: allow_inferred_rendering, **rendering, &block) | ||
|
||
turbo_stream_action_tag name, target: target, template: template | ||
turbo_stream_action_tag name, target: target, template: template, **attributes_from_method(method) |
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.
I think there's no need for attributes_from_method
, could simply be replaced by , method: method
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.
DONE
e529329
to
82ae81e
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.
👍 🙌
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.
Thank you so much for opening this, I was just looking for it! :)
@@ -23,6 +23,7 @@ class Turbo::StreamsControllerTest < ActionDispatch::IntegrationTest | |||
<turbo-stream action="replace" target="message_1"><template>#{render(message_1)}</template></turbo-stream> | |||
<turbo-stream action="replace" target="message_1"><template>Something else</template></turbo-stream> | |||
<turbo-stream action="replace" target="message_5"><template>Something fifth</template></turbo-stream> | |||
<turbo-stream method="morph" action="replace" target="message_5"><template>Something fifth</template></turbo-stream> |
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.
Maybe also cover the action="update"
case in exactly the same way?
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.
update not covered at all as you see but anyway added with morph :)
115a320
to
903eec4
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.
Looks great. 👍
Looks good to me! Eager to use this functionality in my rails project shortly. |
Thanks for this PR, @AlexKovynev Anything in particular holding it up at this point?? |
@dhh can it be merged somehow please? Cause this thing now missed when morph added. |
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 @AlexKovynev 🙏
I'll release a new version with this one later today. |
continue of this #658