Foreach loop in jade (node.js template engine)

前端 未结 3 1755
星月不相逢
星月不相逢 2020-12-29 03:31

Ok, I am getting an associative array from node server and trying to render it in Jade. I obviously need a foreach loop, but nothing seems to work! I tried these both codes:

相关标签:
3条回答
  • 2020-12-29 03:48

    Your second example would work except you have a small syntax error in it - an extra parentheses, it should be:

    - rows.forEach(function(item) {
      li= item
    - })
    
    0 讨论(0)
  • 2020-12-29 03:48

    You can use

    ul
      each val, index in ['zero', 'one', 'two']
        li= index + ': ' + val
    

    or

    ul
      each val, index in {1:'one',2:'two',3:'three'}
        li= index + ': ' + val
    

    see this link

    0 讨论(0)
  • 2020-12-29 04:05

    try

    each item in rows
        li= item
    
    0 讨论(0)
提交回复
热议问题