Skip to content

Support different formats #1062

Description

@vpereira

Reading the code https://github.com/github/view_component/blob/0fd7cbf087248f3ce9c0becb4a00f598e361e3ea/lib/view_component/base.rb#L416 and documentation, I'm unsure we are able to use different formats like :xml or :text, right?

Problem:

I have a component that I want to render as :html and :text. For that, I created two views for my component, (i.e foo_component.html.haml and foo_component.text.haml. Somehow I expected to be able to pass the format to render, however I'm not able to, right?

Possible solution:

To render text "inline", I should have a method call to my class where I bypass any assigned template and render a string inline

Update

looks like I cannot have a template (i.e foo_component.html.haml) and implement the call method to deal with the inline rendering in the same class

Is that correct or did I miss anything? Any idea how to deal with that?

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