Trying to figure out generating html in controller

So I have some old code that used to work and I am trying to
resurrect it.

The controller has this:

for i in 0…w.size
@content = @content + "<span id=“w#{i}” style=‘display:none’>
#{w[i]} "
@content = “<div style=“font-size:100;color:blue;”>” + @content +

@txt_divs = “”
for i in 0…5
span = “”
for j in 0…10
span = “#{span} </
div = "

@txt_divs << div << “\n”

In the view I then do this:

<%= @content%>

<%= @txt_divs %>

but what’s get generated is this as literal text and not what I wanted
or what used to work:

<div style=“font-size:100;color:blue;”><span
id=“w0” style=‘display:none’> Free </span><span
id=“w1” style=‘display:none’> Spirit </
span><span id=“w2” style=‘display:none’> Boston
</span><span id=“w3” style=‘display:none’> </

<div> <span id=‘sp0_0’ style=‘display:none’> </
span> <span id=‘sp0_1’ style=‘display:none’> </span>
<span id=‘sp0_2’ style=‘display:none’> </span> <span
id=‘sp0_3’ style=‘display:none’> </span> <span id=‘sp0_4’
style=‘display:none’> </span> <span id=‘sp0_5’
style=‘display:none’> </span> <span id=‘sp0_6’
style=‘display:none’> </span> <span id=‘sp0_7’
style=‘display:none’> </span> <span id=‘sp0_8’
style=‘display:none’> </span> <span id=‘sp0_9’
style=‘display:none’> </span> <span id=‘sp0_10’
style=‘display:none’> </span> </div>

<div> <span id=‘sp1_0’ style=‘display:none’> </
span> <span id=‘sp1_1’ style=‘display:none’> </span>
<span id=‘sp1_2’ style=‘display:none’> </span> <span
id=‘sp1_3’ style=‘display:none’> </span> <span id=‘sp1_4’
style=‘display:none’> </span> <span id=‘sp1_5’
style=‘display:none’> </span> <span id=‘sp1_6’
style=‘display:none’> </span> <span id=‘sp1_7’
style=‘display:none’> </span> <span id=‘sp1_8’
style=‘display:none’> </span> <span id=‘sp1_9’
style=‘display:none’> </span> <span id=‘sp1_10’
style=‘display:none’> </span> </div>

<div> <span id=‘sp2_0’ style=‘display:none’> </
span> <span id=‘sp2_1’ style=‘display:none’> </span>
<span id=‘sp2_2’ style=‘display:none’> </span> <span
id=‘sp2_3’ style=‘display:none’> </span> <span id=‘sp2_4’
style=‘display:none’> </span> <span id=‘sp2_5’
style=‘display:none’> </span> <span id=‘sp2_6’
style=‘display:none’> </span> <span id=‘sp2_7’
style=‘display:none’> </span> <span id=‘sp2_8’
style=‘display:none’> </span> <span id=‘sp2_9’
style=‘display:none’> </span> <span id=‘sp2_10’
style=‘display:none’> </span> </div>

<div> <span id=‘sp3_0’ style=‘display:none’> </
span> <span id=‘sp3_1’ style=‘display:none’> </span>
<span id=‘sp3_2’ style=‘display:none’> </span> <span
id=‘sp3_3’ style=‘display:none’> </span> <span id=‘sp3_4’
style=‘display:none’> </span> <span id=‘sp3_5’
style=‘display:none’> </span> <span id=‘sp3_6’
style=‘display:none’> </span> <span id=‘sp3_7’
style=‘display:none’> </span> <span id=‘sp3_8’
style=‘display:none’> </span> <span id=‘sp3_9’
style=‘display:none’> </span> <span id=‘sp3_10’
style=‘display:none’> </span> </div>

<div> <span id=‘sp4_0’ style=‘display:none’> </
span> <span id=‘sp4_1’ style=‘display:none’> </span>
<span id=‘sp4_2’ style=‘display:none’> </span> <span
id=‘sp4_3’ style=‘display:none’> </span> <span id=‘sp4_4’
style=‘display:none’> </span> <span id=‘sp4_5’
style=‘display:none’> </span> <span id=‘sp4_6’
style=‘display:none’> </span> <span id=‘sp4_7’
style=‘display:none’> </span> <span id=‘sp4_8’
style=‘display:none’> </span> <span id=‘sp4_9’
style=‘display:none’> </span> <span id=‘sp4_10’
style=‘display:none’> </span> </div>

<div> <span id=‘sp5_0’ style=‘display:none’> </
span> <span id=‘sp5_1’ style=‘display:none’> </span>
<span id=‘sp5_2’ style=‘display:none’> </span> <span
id=‘sp5_3’ style=‘display:none’> </span> <span id=‘sp5_4’
style=‘display:none’> </span> <span id=‘sp5_5’
style=‘display:none’> </span> <span id=‘sp5_6’
style=‘display:none’> </span> <span id=‘sp5_7’
style=‘display:none’> </span> <span id=‘sp5_8’
style=‘display:none’> </span> <span id=‘sp5_9’
style=‘display:none’> </span> <span id=‘sp5_10’
style=‘display:none’> </span> </div>

On May 24, 2011, at 12:16 PM, Jedrin wrote:

div = "


<%= @txt_divs %>

<%= raw @content %>

Seems like you should move that into the view if you can though…


On Tuesday, May 24, 2011 1:33:26 PM UTC-6, Philip wrote:

for j in 0…10
In the view I then do this:

Additionally, as you take Philip’s suggestion, you ought to consider the
power of using partials:

Specifically, check out section 3.4.5, “Rendering Collections”