Skip to content

Solution for conditional partial layout? #1082

Closed Answered by BlakeWilliams
jrochkind asked this question in Q&A
Discussion options

You must be logged in to vote

I've seen capture used for cases like this.

e.g.

<% content = capture do %>
  my body content here
<% end %>

<% if wrap_with_layout? %>
  <%= render MyLayoutComponent.new do %>
    <%= content %>
  <% end %>
<% else %>
  <%= content %>
<% end %>

Replies: 4 comments 11 replies

Comment options

You must be logged in to vote
11 replies
@jrochkind
Comment options

@rmacklin
Comment options

@boardfish
Comment options

@jrochkind
Comment options

@jrochkind
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by joelhawksley
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants