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
Yajl support #85
Yajl support #85
Conversation
This template is largely inspired by the Nokogiri and Builder templates.
This template works pretty well, but I just noticed a possible gotcha. The template assumes the last statement is the "data" you want to convert to json. It might probably be a good idea to have a I'll experiment a little bit to see if it makes sense. |
What about wrapping it in something like this?
|
👍 This would be awesome with sinatra-respond-with. |
Hi @rkh, Before I forgot to do that, thanks for the huge amount of |
In this way, the template is even more flexible. I added some documentation to document the features.
I made a small refactoring in order to use a buffer variable (the gotcha is now fixed) and added some documentation. |
It makes sense. I updated the code. All tests pass. |
I'm all for including it. |
Hmm. I like it. It's non-invasive by taking only the |
This branch adds JSON template support using
Yajl
.The template is largely inspired by Builder and Nokogiri templates.
The idea originated creating a web service with Sinatra.
Quite often I find myself working with JSON responses (especially now that is the de-facto standard for AJAX script) and I found very useful to be able to write JSON templates like you can do with Builder.
I used Yajl because it's very efficient and, as a bonus,
.yajl
extension is not confusing like.json
would be for a template file containing Ruby code.