- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
<%
def out_categories(parent, level)
if (categ = @categories.where(parent_id: parent))
categ.each do |cat|
%>
<div style='margin-left:<%=level * 20%> px'><%= cat.title %></div>
<%
level += 1
out_categories(cat.id, level)
level -= 1
end
end
end
out_categories(nil, 0)
%>
Follow us!
out_categories(cat.id, ++level--)
Только сука японец мог догадаться до такого синтаксиса.
Намного хуже читается Жуквери: $(categ).each(function(index, cat) {...}), от которого categ.each do |cat| отличается только тем, что скобочек поменьше.
https://www.npmjs.com/search?q=foreach
You are a great soft jelly thing. Smoothly rounded, with no mouth, with pulsing white holes filled by fog where your eyes used to be. Rubbery appendages that were once your arms; bulks rounding down into legless humps of soft slippery matter.
А если вдруг захочется вложенности, можно просто использовать и чередовать два вида скобок: