'nother question on erb/eruby

G

Greg Brondo

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:

<html>
<body>
<% puts "Hello World" %>
</body>
</html>

Will output:

Hello World

<html>
<body>
</body>
</html>


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

Thanks!
Greg B.
 
D

Dick Davies

Greg said:
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
<html>
<body>
Hello World
</body>
</html>
0rasputin@lb:sieves$ cat erb.html
<html>
<body>
<%= "Hello World" %>
</body>
</html>


I guess the eruby stuff would be useful - see:

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

Greg Brondo

Dick said:
You don't generally use 'puts' to generate the content, try

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


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.
 
C

Charles Comstock

Dick said:
You don't generally use 'puts' to generate the content, try

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


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
 
M

Mark Hubbart

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?

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
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top