Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Format #4

Open
mhemesath opened this issue Jan 24, 2011 · 0 comments
Open

JSON Format #4

mhemesath opened this issue Jan 24, 2011 · 0 comments

Comments

@mhemesath
Copy link

A great benefit to using mustache is the ability to reuse the views on the client. The gem should return the JSON representation of the mustache view when a JSON request is made.

Ideally this would require no additional effort on the controller. For example, this action below should return the rendered mustache if HTML is requested, or the JSON representation of the view if JSON is requested.

def index
@users = User.all
respond_with(@users)
end

Right now I'm looking into a mustache custom responder to intercept JSON requests and create a mustache view and call view.to_json instead of the default behavior of @users.to_json that would typically occur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant