ERB generates unwanted EOLs

  • Thread starter Robert William Vesterman
  • Start date
R

Robert William Vesterman

If I add any inline code to an ERB template, extraneous end of line
characters are generated. For example, I want to generate the output:

#include "x.h"
#include "y.h"
#include "z.h"

So I have a template that's something like:

<% headers.each { |name| %>
#include "<%= name %>"
<% } %>

Instead of the output that I want, this generates:

#include "x.h"

#include "y.h"

#include "z.h"


I can get the output that I want in this case by doing something like:

<% headers.each { |name| %>
#include "<%= name %>"<% } %>

But that's only good in relatively trivial cases like this - if I want
to put a large amount of code inline, there's virtually no way I won't
be getting lots and lots of extraneous EOLs.

I gather, from the book "Code Generation in Action" by Jack
Herrington, that this is not supposed to happen - that is, my expected
output is the output that is supposed to happen.

Am I doing something wrong? Do I have something misconfigured? Is
there a way to fix this problem?

I am running Ruby on Windows XP, in case that matters.

Thanks in advance for any help.

Bob Vesterman.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,142
Messages
2,570,820
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top