玉的Foreach循环(node.js模板引擎) [英] Foreach loop in jade (node.js template engine)

查看:212
本文介绍了玉的Foreach循环(node.js模板引擎)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我正在从节点服务器获取一个关联数组,并试图在Jade中渲染它。我显然需要一个foreach循环,但似乎没有任何工作!我试过这两个代码:

pre $ - foreach row in rows {
li = row
- }

  li = item 
- })

我传递的数组叫做rows。任何想法,为什么这是行不通的?我得到这个错误:

  500 SyntaxError:意外的标识符

和第二个代码:

  500 SyntaxError:意外的令牌)


解决方案

try

 行中的每个项目
li =项目


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:

- foreach row in rows {
    li= row
- }

and

- rows.forEach(function(item)) {
    li= item
- })

the array I am passing is called "rows". Any idea why this is not working? I am getting this error:

500 SyntaxError: Unexpected identifier

and, with the second code:

500 SyntaxError: Unexpected token )

解决方案

try

each item in rows
    li= item

这篇关于玉的Foreach循环(node.js模板引擎)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆