Closed toncid closed 5 years ago
Is it possible to set a simple field value that is result of a do-end block:
do-end
json.some_field do if some_condition? 42 else 13 end end
This would result with some_field as either 42 or 13 ({"someField": 42}), but in reality it is fully omitted from the output JSON.
some_field
{"someField": 42}
json.some_field begin if some_condition? 42 else 13 end end
Instead of giving your block to Jbuilder, evaluate it, and give Jbuilder the result.
Thanks!
Is it possible to set a simple field value that is result of a
do-end
block:This would result with
some_field
as either 42 or 13 ({"someField": 42}
), but in reality it is fully omitted from the output JSON.