File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -337,10 +337,32 @@ json.posts do
337337end
338338```
339339
340- Usage for rendering partial without assigning it to some key:
340+ Rendering partials without a key is also supported using ` json.partial! ` , but use
341+ sparingly! ` json.partial! ` is not optimized for collection rendering and may
342+ cause performance problems. Its best used for things like a shared header or footer.
343+
344+ Do:
345+
346+ ``` ruby
347+ json.partial! partial: " header" , locals: {user: @user } do
348+ end
349+ ```
350+
351+ or
341352
342353``` ruby
343- json.partial! partial: " posts/blog_post" , locals: {post: @post } do
354+ json.posts do
355+ json.array! @posts , partial: [" posts/blog_post" , locals: {post: @post }] do
356+ end
357+ end
358+ ```
359+
360+ Do NOT:
361+
362+ ```
363+ @post.each do |post|
364+ json.partial! partial: "post", locals: {post: @post} do
365+ end
344366end
345367```
346368
Original file line number Diff line number Diff line change 11require_relative "support/helper"
2+ require_relative "support/rails_helper"
23
34RSpec . describe "Props::Base" do
45 it "initializes" do
You can’t perform that action at this time.
0 commit comments