See the Sinatra bug report at:
http://sinatra.lighthouseapp.com/projects/9779/tickets/24-running-on-jruby-fails-at-rendering-erb-templates
Copied from the original bug report:
The sinatra app (app.rb):
require '../sinatra/lib/sinatra.rb'
get '/' do
"Hello World"
end
get '/:foo' do
erb :foo
end
The template (views/foo.erb):
<html>
<head></head>
<body>Erb rendered</body>
</html>
The command to run the application:
jruby app.rb
The error:
Params:
{"foo"=>"blah"}
LocalJumpError - yield called out of block
The working part:
Going to '/' returns "Hello World" just as expected. Using a Haml renderer works fine as well.
It appears that layouts in general are the issue, and not erb, haml or any other particular renderer. The error remains the same.
views/layout.erb
------
<html>
<head></head>
<body>
<p>Layout rendered</p>
<%= yield %>
</body>
</html>
views/layout.haml
------
%html
%body
#content= yield
views/foo.haml
--------
%p Hello World
Of course to change to using the haml renderer, you have to change the "erb :foo" line to "haml :foo".
Also, as a bit of background for people who haven't seen Sinatra before, basically, you map URLs to actions. The line "get '/:foo' do" sets up a handler for /foo, /bar, /baz and so on. The :foo part denotes a variable that can be accessed via params[:foo], this feature is not used here. I realize that there might be a bit of confusion by my repeated use of "foo".