http icon indicating copy to clipboard operation
http copied to clipboard

JSON view block

Open vladfaust opened this issue 6 years ago • 2 comments

  json @worlds.map do |world|
    Views::World.new(world)
  end

Is treated as builder variant and

json @worlds.map { |world| Views::World.new(world) }

Is not.

vladfaust avatar Mar 24 '19 12:03 vladfaust

Also doesn't work for

json tips: @tips.map do |tip|
  View::Tip.new(tip)
end
   7.     def render_to_application_json(io : IO)
>  8.       ({tips: @tips.map}).to_json(io)
   9.     end

'Array(Models::Tip)#map' is expected to be invoked with a block, but no block was given

vladfaust avatar May 13 '19 13:05 vladfaust

Should put more thought into it. Given:

json content_type: "application/json-a" do
  builder do
    field "foo", @foo
    field "bar", @bar
  end
end

What if I just wanted to add builder block arg?

json content_type: "application/json-a" do |builder|
  builder do
    field "foo", @foo
    field "bar", @bar
  end
end

vladfaust avatar May 28 '19 21:05 vladfaust