Module: Wunderbar::Template::Json
- Defined in:
- lib/wunderbar/sinatra.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.ext ⇒ Object
129 |
# File 'lib/wunderbar/sinatra.rb', line 129 def self.ext; ['json.rb', :_json]; end |
.mime ⇒ Object
130 |
# File 'lib/wunderbar/sinatra.rb', line 130 def self.mime; 'application/json;charset=utf-8'; end |
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/wunderbar/sinatra.rb', line 132 def evaluate(scope, locals, &block) builder = JsonBuilder.new(scope) begin result = _evaluate_safely(builder, scope, locals, &block) # if no output was produced, use the result builder._! result if builder.target? == {} and result rescue Exception => exception scope.content_type self.class.default_mime_type, :charset => 'utf-8' scope.response.status = 500 builder._exception exception end scope.cache_control :no_cache builder.target! end |