From: Robert Klemme Date: 2009-12-05T02:27:15+09:00 Subject: Re: using heredoc string in erb 2009/12/4 jakemiles : > Thanks!  The .chomp fixed it. For me moving the "%>" to the next line fixed it. > No, the intention isn't to create helper functions in Java.  The web > page happens to be a tutorial on Java.  The helper function is a ruby > helper that appliers google's syntaxhighlighting javascript thing to > the provided block of text. > > The resulting code in the view, for posterity, is: > >  <%= 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 > %> > > And the helper function it calls is this: > >  def code(lang, block) >    "" >  end > > This turns the provided block of code into this HTML: > >   > > Which is the syntax for the syntaxhighlighter package that syntax- > highlights the code in the page andmakes it look quite sharp.  The > helper will also automagically include the right javascript file for > the language of the formatted code block. Erm, why do you need a helper function for this? Why not directly place this in the ERB template Or even do <%= CODE_INTRO_JAVA %> // 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_END %> with proper definitions of both constants? What am I missing? Kind regards robert PS: Please do not top post. -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/