Conversation
|
Hi! Thanks for commenting and trying out superglue! I'm not quite ready for the proposed change.
Yup!
You can still use jbuilder, as long as its on a different route. Or if you really prefer, superglue.js just expects a JSON response so you can create a |
|
@jho406 Understandable! I've changed the PR to use Props::Handler.default_format in place of hardcoded :json symbols. This should let users override it if they want, and register their own mimetype |
|
@joshleblanc Thanks! I'm more open to that change. Would it be possible to add a test case for it? |
I was playing around with Superglue in a hobby app, which uses the same controller for html views and api calls. So games/show.json would be your json response, and games/show.html would be your html response.
When you install superglue, it assumes that your json response will be the props, so any jbuilder templates will no longer function in favor of the prop templates. This didn't feel right, so I went poking around at adding a new mime type.
This PR allows specifying the format for a request as
:propsrather than:json. Your file would have to be names[name].props.pbuilderto be picked up properly.Note that I changed the name of the file to
pbuilderinstead ofprops. This was just to get it working so I had something to show. The reason it's changed is because the file format is[name].[format].[handler]. Without changing the name of either the mime type or the handler, the format ends up being[name].props.props, which looks awful.--
If you want to test this in a superglue app, the following changes need to be made
app/layouts/application.json.props to app/layouts/application.props.pbuilderformats: [:json]toformats: [:props]in your erb views.json.propsfiles to.props.pbuilder