Skip to content

Rendering nested JBuilder partials requires formats: [:json] to be passed #134

Closed
@petedmarsh

Description

@petedmarsh

I render JSON using inside some HAML views in order to ship along an initial blob of JSON to the client. Since the change in #120 I have found that rendering JSON/JBuilder partials is a little bit more cumbersome as formats: [:json] is no longer passed by default.

Where previously I had written:

json.partial! 'xs/x', my_local: @some_value

I now have had to change this to:

json.partial! partial: 'xs/x', formats: [:json], locals: { my_local: @some_value }

If I do not pass formats: [:json] I get a "Template not found" error. Ideally I'd like to go back to something like the original. Admittedly this only happens as I am rending a JBuilder template with nested partials into a HAML view, so perhaps it is too rare a use case to support directly.

My initial thought was a new method which is like partial! but can only render other JBuilder templates. After thinking about it for a little while, it's probably not a good solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions