The answer, I learned from a reply on the Ruby thread, requires two
smalll changes, shown in the code here:
<%= code "java", <<-CODE.chomp
// create a panel using a GridBagLayout
JPanel panel = new JPanel (new GridBagLayout());
// three labels on the first row
panel.add (new JLabel ("One"));
panel.add (new JLabel ("Two"));
panel.add (new JLabel ("Threeeee"));
CODE
%>
Call chomp on heredoc delimiter (which, I infer, is a ruby string
object at the time of parsing), and make sure the %> is on its own
line after the end delimiter.
Very cool - this makes a lot of cool helper methods possible. For
example, if you want to parse a block of HTML to modify it you can do
that fairly unobtrusively this way.