How to render from with <%%>?

I have a loop that I iterate through in my view.

<%
coll.each do |itm|
puts(itm.value)
end
%>

How do I render the itm.value without using a <%= %> tag? Should puts
not work?

Joerg

P.S. There is a good enough reason for me wanting to do this :slight_smile:

Joerg D. wrote:

Joerg

P.S. There is a good enough reason for me wanting to do this :slight_smile:

<% coll.each do |itm| -%>
<%= itm.value %>
<% end -%>

–
Arie Kusuma A. A.K.A Arie A.K.A ariekeren / YM! = riyari3
http://ariekusumaatmaja.wordpress.com
Let’s build Ruby Indonesia stronger
Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos # Indonesia Ruby Society

500 baris di PHP dkk VS 1 baris di Ruby dkk
300 baris di Java dkk VS 1 baris di Ruby dkk
Macih ngotot pake (as|ph)p? haree geneee???
Buat yang pake Ruby, nyesel kan lu pake Ruby!!! kenapa ga dari dulu?!

You can’t use puts in views.

What is it you’re trying to do? You’ll have to give us the good enough
reason i think :0)

Steve

<%= coll.collect(&:value).join %>

You can use the ‘concat’ method instead of ‘puts’:

<%
coll.each do |itm|
concat(itm.value, binding)
end
%>

Cheers,

-DF

Hi –

On Wed, 31 May 2006, Joerg D. wrote:

I have a loop that I iterate through in my view.

<%
coll.each do |itm|
puts(itm.value)
end
%>

How do I render the itm.value without using a <%= %> tag? Should puts
not work?

puts doesn’t append its arguments to the _erbout variable, which is
where erb accumulates its output.

You could do:

<% coll.each {|itm| _erbout << itm.value } %>

or something like that, though that’s really what <%= %> is for :slight_smile:

David

–
David A. Black ([email protected])