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.

On Dec 4, 5:17 am, jakemiles <[email protected]> wrote:
> Hi all.  I'm trying to write a helper function that will let me use
> something like the following in my view, where I can pass in a text
> block as the last argument:
>
> <%= code "java", <<-CODE
>
>         // 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 %>
>
> but this produces this error in the merb console (and merb dies):
>
> can't find string "CODE" anywhere before EOF
>
> So it can't find the end of the heredoc.  Does anyone know how to get
> this to work?  I suspect it's more of an erb issue than merb, but I
> thought the hacker mentality might be able to solve this one. :)
>
> Thanks for any help.
>
> - Jake

--

You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/merb?hl=en.


Reply via email to