Created
December 21, 2016 21:11
-
-
Save danott/36f9ccf3e249b1ab232bd4c82e2c04e3 to your computer and use it in GitHub Desktop.
An example of the gymnastics to use `content_for` blocks between a view and partial, where the partial is supposed to appear after the `content_for` block
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% content_for :content_set_within_partial do %> | |
"Hello! I'm setting a content_for block within a partial" | |
<% end %> | |
Hello!, I'm actually rendered in the partial |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% captured_partial_render_to_get_ordering_right = capture do %> | |
<%= render partial: "partial_that_sets_content_for_block" %> | |
<% end %> | |
<%= content_for :content_set_within_partial %> | |
<%= captured_partial_render_to_get_ordering_right %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment