'nother question on erb/eruby

Ok, I’ve got it kinda working (erb) that is…eruby doesn’t want to compile
for me (I’m still a bit new to working with Makefiles – cannot find
ruby.h).

Anyway, I can run erb like so: erb blah.rhtml

The problem is any ruby ‘puts’ statements appear first in the actual output.

blah.rhtml example:

<% puts "Hello World" %>

Will output:

Hello World

And my last question is what is preferred in a cgi setup? erb or eruby?

Thanks!
Greg B.

Greg Brondo wrote:

Ok, I’ve got it kinda working (erb) that is…eruby doesn’t want to compile
for me (I’m still a bit new to working with Makefiles – cannot find
ruby.h).

Anyway, I can run erb like so: erb blah.rhtml

The problem is any ruby ‘puts’ statements appear first in the actual output.

You don’t generally use ‘puts’ to generate the content, try

0rasputin@lb:sieves$ erb erb.html


Hello World


0rasputin@lb:sieves$ cat erb.html


<%= “Hello World” %>

I guess the eruby stuff would be useful - see:

http://www.rubydoc.org/books/modruby/c277.htm

Dick Davies wrote:

Greg Brondo wrote:

Ok, I’ve got it kinda working (erb) that is…eruby doesn’t want to
compile for me (I’m still a bit new to working with Makefiles – cannot
find ruby.h).

Anyway, I can run erb like so: erb blah.rhtml

The problem is any ruby ‘puts’ statements appear first in the actual
output.

You don’t generally use ‘puts’ to generate the content, try

0rasputin@lb:sieves$ erb erb.html


Hello World


0rasputin@lb:sieves$ cat erb.html


<%= “Hello World” %>

I guess the eruby stuff would be useful - see:

http://www.rubydoc.org/books/modruby/c277.htm

Thanks for the info! I guess what I need is which is more stable/feature
filled, etc…

Thanks again!
Greg B.

Dick Davies wrote:

Greg Brondo wrote:

Ok, I’ve got it kinda working (erb) that is…eruby doesn’t want to
compile
for me (I’m still a bit new to working with Makefiles – cannot find
ruby.h).

Anyway, I can run erb like so: erb blah.rhtml

The problem is any ruby ‘puts’ statements appear first in the actual
output.

You don’t generally use ‘puts’ to generate the content, try

0rasputin@lb:sieves$ erb erb.html

Hello World 0rasputin@lb:sieves$ cat erb.html <%= "Hello World" %>

I guess the eruby stuff would be useful - see:

http://www.rubydoc.org/books/modruby/c277.htm

Hmm, it’s pretty general practice in all the other embedded languages
that use the <% %> style coding to be able to also print directly in the
language, ie sometimes it makes more sense. Is there a particular
reason the code generation places the puts before hand? I mean from my
reading of the way erb works it shouldn’t be doing that? Anyone have an
explanation to this behavior?

Charles Comstock

erb builds the page piece by piece as a string, then outputs it when
done processing; anything #printed out along the way comes out first
because the rest of the page gets printed out all at once at the end.
You can see the script it builds by calling erb with the -x option.
(strangely, the generated script doesn’t output the string at the end,
so the script will not run properly…)

I think you are right… it doesn’t make sense to me that erb should do
it this way. If it’s going to buffer it to a string, that makes sense;
but I think it should override Kernel#print and #puts to concatenate to
the buffer…

–Mark

···

On Apr 8, 2004, at 11:14 PM, Charles Comstock wrote:

Hmm, it’s pretty general practice in all the other embedded languages
that use the <% %> style coding to be able to also print directly in
the language, ie sometimes it makes more sense. Is there a particular
reason the code generation places the puts before hand? I mean from
my reading of the way erb works it shouldn’t be doing that? Anyone
have an explanation to this behavior?