amatsuda/jb

When partial returns nil, the result of `nil.to_s` is overwritten

Closed this issue · 1 comments

how to reproduce

  1. prepare a partial template
  2. the partial template returns nil

this is an example

# foo.json.jb
{
  p: render(partial 'bar')
}

# _bar.json.jb
return if true
{
  age: 10,
  name: 'name'
}

versions
jb: 0.8.1
ruby: 3.2.2
rails: 7.1.1

I guess fb4b0de has overwritten the NilClass object behavior.
Do you expect a partial to be implemented that return Hash or Array?

@Niyokee Thank you for reporting this!

Do you expect a partial to be implemented that return Hash or Array?

While I would answer "yes" to this question, a template engine should of course never change nil object's behavior anyway. I made a fix on af5997e and published a new release versioned 0.8.2 with this fix.

Thanks!