如何制作跨越多条线的haml-coffee封口?

Bil*_*lly 5 syntax haml coffeescript hamlc

我试图在我的一个模板中添加少量逻辑(请不要骂我在视图中放置逻辑的错误)并且很难获得正确的hamlc语法.

我正在迭代一个集合,并希望跳过另一个集合中存在的元素

直接的咖啡因看起来像:

for artwork in artworks
  unless _.find(cart_items, (ci) ->
    ci.id == artwork.product_code
      alert 'artwork not in cart'
Run Code Online (Sandbox Code Playgroud)

我尝试着:

- for artwork in artworks
  - unless _.find(cart_items, (ci) -> | # < multiline, right?
    ci.id == artwork.product_code
    - alert 'artwork not in cart'
Run Code Online (Sandbox Code Playgroud)

我正在得到一些关于:

Block level too deep in line undefined
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?蒂莉,比利

Bil*_*lly 1

我可以通过将闭包放在同一行来使其工作:

- for artwork in artworks
  - unless _.find(cart_items, (ci) -> ci.id == artwork.id)
    - alert 'not in the cart'
Run Code Online (Sandbox Code Playgroud)