jbuilder icon indicating copy to clipboard operation
jbuilder copied to clipboard

Passing a block to a partial

Open samstarling opened this issue 6 years ago • 3 comments

Hello! Is there any way to pass a block to a partial? For example like this

json.partial!('member', member: @member) do
  json.total_loans(@member.total_loans)
end

In the partial, it looks like this:

json.id member.id
json.type member.class
json.attributes do
  json.name member.name
  json.date_of_birth member.date_of_birth
  yield
end

But it doesn't work. Any ideas?

samstarling avatar Mar 16 '18 16:03 samstarling

+1 for this

scriptfans avatar Apr 29 '18 14:04 scriptfans

+1

tien7668 avatar Dec 07 '18 03:12 tien7668

Is there any news for this feature?

scriptfans avatar Feb 20 '21 10:02 scriptfans