Skip to content

Instantly share code, notes, and snippets.

@danott
Created December 21, 2016 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danott/36f9ccf3e249b1ab232bd4c82e2c04e3 to your computer and use it in GitHub Desktop.
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
<% 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
<% 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