下面的pyjade代码会导致内部服务器错误。当#{module.key}被带到href之外时,它可以正常工作。有什么想法吗?
table
// the table isn't working perfectly but leo is making responsive
// anyway, will merge that version
each module, m in modules
if (m % 5 == 0)
tr
td
a(href='#{module.key}') #{module.name}
else
td
a(href="#{module.key}") #{module.name}

发布于 2014-02-28 02:03:06
我们要做的是在后端将数组划分成一个2D数组,然后在玉器模板中的行上迭代。在每一行迭代中,编写一个tr并遍历该行的cols。在迭代cols时,编写td及其内容。
发布于 2014-02-17 23:21:45
基于这个错误,它抱怨使用这一行的TypeError和each module, m in modules,并查看翡翠迭代的文档,http://jade-lang.com/reference/#iteration向我建议,迭代中导出的索引是一个字符串。
你应该试试
each module, m in modules
(int(m) % 5 == 0)发布于 2014-02-21 10:06:00
它是pyjade Python包的创建者Syrus。碧玉不会将你的vars作为字符串投射到#{}中,所以你必须自己去做。
下面的示例应该有效
table
// the table isn't working perfectly but leo is making responsive
// anyway, will merge that version
each module, m in modules
if (m % 5 == 0)
tr
td
a(href='#{str(module.key)}') #{module.name}
else
td
a(href="#{str(module.key)}") #{module.name}https://stackoverflow.com/questions/21839900
复制相似问题