node.js - 如何在 Jade 中反向迭代 for 循环?

标签 node.js for-loop pug

ul.blogpostGrid
for child in page.get('/posts').children
    a(href=child.url): li.col.span_1_of_4 
        h2 #{child.title}
        div.imgThumb(style='background-image: url(#{child.url}thumb.jpg);')
        p #{child.excerpt}

For 循环当前按创建的升序显示博客文章。如何反转它们的显示顺序? 有反转功能吗?如果是的话,在这种情况下如何实现? 我正在使用伍兹cms。 https://github.com/studiomoniker/woods

最佳答案

这有帮助。

for child in page.get('/posts').children.reverse()

关于node.js - 如何在 Jade 中反向迭代 for 循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32291916/

相关文章:

java - Nodejs和java套接字实现错误: connect ECONNREFUSED 127. 0.0.1:8081

node.js - ibm bluemix Node js 文件

node.js - STM MP157C DK2 Node.js 可以吗?

javascript - Promise Chain似乎没有继续

templates - Jade 模板作为 html 的预处理器

Javascript - 检查经纬度坐标是否在边界内

java - For循环不打印用户输入

c - 我的 for 循环是否有问题导致它在屏幕上显示不正确的星号?

html - pug Pretty 选项 - HTML 输出中 'a' 标记后的新行

AjAX post 请求重定向页面时出现问题