Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JRuby 1.1.3
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:HideWindows Vista
Sinatra Edge as of 5/31/2007 (http://github.com/bmizerany/sinatra/tree/master)
64 Bit version of Java
$ java -version
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)ShowWindows Vista Sinatra Edge as of 5/31/2007 (http://github.com/bmizerany/sinatra/tree/master) 64 Bit version of Java $ java -version java version "1.6.0_05" Java(TM) SE Runtime Environment (build 1.6.0_05-b13) Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
-
Number of attachments :
Description
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.
Attachments
Issue Links
| This issue is related to: | ||||
| JRUBY-2605 | Kernel.eval with yield behaves differently than MRI 1.8.6/1.8.7, causes some libraries failures with JRuby |
|
|
|
On further investigation, it appears I have a rouge layout in the views directory that I didn't notice. I only had one for erb, and not for haml, which mislead me to think that Erb was the problem.
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".