jbuilder
https://github.com/rails/jbuilder
Ruby
Jbuilder: generate JSON objects with a Builder-style DSL
JbuilderTemplate#cache_root!
Caches the json structure at the root using a string rather than the hash structure. This is considerably faster, but the drawback is that it only works, as the name hints, at the root. So you cannot use this approach to cache deeper inside the hierarchy, like in partials or such. Continue to use #cache! there. Example: json.cache_root! @person do json.extract! @person, :name, :age end # json.extra 'This will not work either, the root must be exclusive'
Edit
git clone git@github.com:rails/jbuilder.git
cd jbuilder
open lib/jbuilder/jbuilder_template.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-JbuilderTemplate-cache_root--for-pr
# Commit to gitgit add lib/jbuilder/jbuilder_template.rbgit commit -m "better docs for JbuilderTemplate#cache_root!"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-JbuilderTemplate-cache_root--for-pr
hub pull-request
# Celebrate!