-
Notifications
You must be signed in to change notification settings - Fork 16
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
content_for block not rendering #58
Comments
Hey, thanks for trying out NicePartials! I think this issue is what #54 fixes. To verify that, can you try replacing <div class="flex justify-between">
<% if partial.content_for? :filters %>
<%= partial.content_for :filters %> # Replace yield here.
<% else %>
<%= render 'teachers/filters', school: school %>
<% end %>
</div> |
Thanks for the quick response @kaspth and for the work on this gem! That fix doesn't seem to work. To add some more details, I tried adding a <div class="flex justify-between">
<% byebug %>
<% if partial.content_for? :filters %>
<%= partial.content_for :filters %>
<% else %>
<%= render 'teachers/filters', school: school %>
<% end %>
</div> And the result of |
Hm, strange, I'm a little stumped as to why nothing would be rendering. What version is this? Just to try something… what happens if you rename the <%= render 'teachers/table', school: @school do |cp| %>
<% cp.content_for :filters do %>
<p> hello world </p>
<% end %>
<% end %> |
I just remembered some more things we can check. What's your Rails version? We're depending on some additions in Rails 6.1+ to automatically yield, but we haven't communicated that yet or warned, what happens if you do this? <!-- views/teachers/_table.html.erb -->
<% yield partial = nice_partial %>
<div class="flex justify-between">
<% if partial.content_for? :filters %>
<%= partial.yield :filters %>
<% else %>
<%= render 'teachers/filters', school: school %>
<% end %>
</div>
<table></table> |
@ilrock hey, is this still an issue? |
Hey @kaspth ! As an example, starting from the README code :
<div class="card">
<%= partial.yield :image %>
<div class="card-body">
<h5 class="card-title"><%= title %></h5>
<% if partial.content_for? :body %>
<p class="card-text">
<%= partial.yield :body %>
</p>
<% end %>
<%= yield %>
</div>
</div> <%= render 'components/card', title: 'Some Title' do |partial| %>
<% partial.content_for :body do %>
BODY
<% end %>
<% partial.content_for :image do %>
IMAGE
<% end %>
<div class="card-footer">
FOOTER
</div>
<% end %> There, neither Adding Though, updating the gem to main branch, fixes this issue without the need of |
Got it, yeah. Right now, the automatic Thank you both for looking into it! |
Hello!
I'm trying out
nice_partials
in a project but I can't seem to get thecontent_for
block to render within my partial. I've got two filesI was expecting
<p> hello world </p>
to be rendered within the partial, instead I keep getting the default content. Am I missing something?The text was updated successfully, but these errors were encountered: