- pull part of your json response from cache and do not pay for re-jsoning it
- return precompiled handlebar templates as jsonp response
Usage
# fast response via precompiled parts result = user.to_json result["tickets"] = cache { CompiledJson.new(tickets.to_json) } render :json => result # handlebar templates or other crazyness result = user.to_json result["tickets"] = CompiledJson.new( 'function(c){ return "foo" + c.name + "bar" }' ) render :json => result
code
class CompiledJson < String # activesupport def encode_json(*args) self end # pure JSON def to_json self end end