这是我的代码在路由块中的结尾。发生的事情是 success_loader 从不渲染,而是 Sinatra 发送空响应(页面为空白)
if v.test
mydata = v.sheetData
end
if v.errors.size == 0
#success
haml :success_loader, :layout => :base,
:locals => {:pub_path => settings.root, :app_ver => settings.version }
else
#fail
haml :failure_loader, :layout => :base,
:locals => {:pub_path => settings.root, :app_ver => settings.version,
:app_error => v.errors }
end
File.delete(target) if File.exists?(target)
使用调试器,我显示从对 haml 的调用开始的点开始的每一行
haml :success_loader, :layout => :base,
:locals => {:pub_path => settings.root, :app_ver => settings.version }
getter = proc { value }
value = :pub_path
getter = proc { value }
value = :apper_ver
File.delete(target) if File.exists?(target)
@params = @original_params
filter! :after unless env['sinatra.static_file']
res = [res] if Fixnum === res or String === res
if Array === res and Fixnum === res.first
status(res.shift)
body(res.pop)
headers(*res)
invoke { error_block!(response.status) }
unless @response['Content-Type'
一堆更多类似的行。然后从 Thin 开始的几行:
log "!! Rack application returned nil body. Probably you wanted it to be an empty string?" if @response.body.nil?
我在路由之外测试了代码,所以它不会抛出任何异常。当在其他路线中使用时,haml 模板可以正常工作。有什么想法吗?