I'm trying to create a dynamic content with yield
and content_for
. Basically i have bunch of layouts. And i dont want to create bunch of views for each layout. I want to render view parts when they are needed. For different parts of code it is ok. But i have problem with same parts with different content.
in my application.html.erb
<%= yield %>
<%= yield :name_section %>
And in my show.html.erb
i have;
<% content_for :name_section do %>
<b>Name:</b>
<%= @post.name %>
<% end %>
Here is the question;
What if i want to multiple name_section with different contents. I mean; I want to put :name_section
different places in my view with different contents.
For ex;
<table>
<tr>
<td>
<%= yield :name_section %>
</td>
</tr>
<tr>
<td>
<%= yield :name_section %>
</td>
</tr>
</table>
Any ideas?
Thank you. Çağdaş