rails / jbuilder

Jbuilder: generate JSON objects with a Builder-style DSL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`json.partial!` line in template is not executed when passing locals using new hash syntax

shunwen opened this issue · comments

I have this line in jbuilder template using the new hash syntax. It seems this line is not executed at all.

json.partial! 'comments', post:, comments:

It works if I modify the line back to the old syntax or add braces or brackets.

json.partial!('comments', post:, comments:)
json.partial! 'comments', { post:, comments: }
json.partial! 'comments', post: post, comments: comments

Could anyone help to explain what happens here? Is it something related to the template compilation? Thanks.

It seems like this should be reopened and fixed as mentioned in the SO answer, i.e adding a semicolon at the end of this line: https://github.com/rails/jbuilder/blob/v2.11.5/lib/jbuilder/jbuilder_template.rb#L277

Especially since Rubocop will suggest removing the hash value if repeated as in the last example