You'll need recursion not iteration. 

Basically you write a method that calls itself n number of times and has an 
exit condition to avoid a race condition. This is a good exercise for a 
beginning programmer, also its surprising how many programmers don't know 
it. So I'll leave it to you as homework and also because I'm at work and 
don't have time. good luck


On Friday, January 15, 2016 at 7:46:52 AM UTC-6, [email protected] wrote:
>
>
> down votefavorite 
> <http://stackoverflow.com/questions/29197186/haml-generate-nested-divs-in-loop#>
>
> Is there any way to generate many divs nested each other?
>
> I expect print some like this:
>
> <div>
>   <div>
>     <div>
>       <div>
>         <div>
>         </div>
>       </div>
>     </div>
>   </div></div>
>
> Simple loop is not helping
>
> - (1..5).each do |i|
>   %div
>
> The result is:
>
> <div></div><div></div><div></div><div></div><div></div>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/haml.
For more options, visit https://groups.google.com/d/optout.

Reply via email to