Class: Wunderbar::Template::Json

Inherits:
Base
  • Object
show all
Defined in:
lib/wunderbar/sinatra.rb

Instance Method Summary collapse

Methods inherited from Base

engine_initialized?, evaluate, #initialize_engine, #precompiled_postamble, #precompiled_preamble, #precompiled_template, #prepare

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/wunderbar/sinatra.rb', line 100

def evaluate(scope, locals, &block)
  builder = JsonBuilder.new(scope)
  begin
    _evaluate_safely(builder, scope, locals, &block)
  rescue Exception => exception
    scope.content_type self.class.default_mime_type, :charset => 'utf-8'
    scope.response.status = 500
    builder._exception exception
  end
  builder.target!
end