在rails视图中跳过迭代

时间:2015-12-04 11:27:07

标签: ruby-on-rails ruby loops

我在.erb文件中有一个循环,如

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc

Dim swSelMgr As SldWorks.SelectionMgr

Dim swView As SldWorks.View

Dim swBomTable As SldWorks.BomTableAnnotation

Dim i As Integer

Dim swTableAnn As SldWorks.TableAnnotation

Dim nNumRow As Variant

Sub main()

 Set swApp = Application.SldWorks

 Set swModel = swApp.ActiveDoc

 Set swSelMgr = swModel.SelectionManager

 Set swBomTable = swSelMgr.GetSelectedObject5(1)

 Set swTableAnn = swBomTable



For i = swTableAnn.RowCount - 1 To 0 Step -1

nNumRow = swBomTable.GetIdForRowNumber(i)


 If nNumRow(i, 9) = "No" Then

swBomTable.Deleterow (nNumRow), True

End If

 Next i

End Sub

是否有一些简单的方法可以根据列名的值跳过迭代?我试着打电话给"接下来"在块内,但它不起作用,因为<%=标记期望输出某些内容。

1 个答案:

答案 0 :(得分:7)

尝试类似:

<% @columns.each do |column| %>
  <% next if condition? %>
  <td><%= column.name %></td>
<% end %>