Open joshleblanc opened 10 months ago
Hi! Thanks for commenting and trying out superglue!
I'm not quite ready for the proposed change.
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.
Yup! props_template
is a DSL that builds JSON. Its is a friendly alternative to jbuilder that competes for the same json
mime type.
so any jbuilder templates will no longer function in favor of the prop templates.
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 games/show.json.jbuilder
instead, but you won't have support for layouts or digging, and will have to build your response to match the page response
@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
:props
rather than:json
. Your file would have to be names[name].props.pbuilder
to be picked up properly.Note that I changed the name of the file to
pbuilder
instead 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.pbuilder
formats: [:json]
toformats: [:props]
in your erb views.json.props
files to.props.pbuilder