-
-
Notifications
You must be signed in to change notification settings - Fork 582
Templates when Rendering from Resource #204
Comments
If you look at the doc (http://gobuffalo.io/docs/generators), the resource generator does the job. It generates actions with a simple string output. I think a resource is something intended to be served as JSON or XML, and is kinda API-oriented. Maybe some documentation improvements can be done here, since the docs does not explain its purpose clearly (http://gobuffalo.io/docs/routing says CRUD, but it's vague). |
I understand the point of resources being used for API-oriented components of the web application, or even to construct API only applications, in that context i agree that the resources are very appropriate and match exactly REST CRUD structure. by this time we don't have JSON templates but would this imply that when using resources we wont be able to have a default template for our response and have the resource function simply fill the template data ? Other than that what i'm trying to say (and sorry not to provide steps initially) is that HTML/JSON/XML are simply representational formats and IMHO our HTML/JSON/XML renderers should behave the same (or at least close) when being called from inside an action than inside a Resource function. just in case i get it wrong, is what you're saying that template skipping is done by propose on resources ? |
Well, it's only my understanding, so I do think it's done on purpose (and the docs displays the result according to this hypothesis).
Sure. I guess you're right, and this example (https://github.com/gobuffalo/buffalo/tree/master/examples/html-resource) shows it can be used to display HTML pages. By looking at the code (https://github.com/gobuffalo/buffalo/blob/master/resource.go), a resource is just a layout to provide default actions. Maybe we can add an option to the resource generator to choose a default template (XML, JSON or HTML)? |
right @stanislas-m seems its not on propose, i still owe some sample code that shows when this is happening. |
oh boy! i may have been doing something wrong on the beginning :( sorry everybody to steal some time and attention, specially @stanislas-m and @bscott, now that i'm retrying it its working correctly, i may have started with the sample code :D, so sorry about the distraction. |
No problem. :) |
I noticed that when generating a resource and rendering html on it buffalo doesn't apply the shared template (application.html by default), but if you generate an action and render html buffalo seems to render the template correctly, is this happening to someone else ?
cc @bscott @markbates
The text was updated successfully, but these errors were encountered: