Reputation: 59
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}
The For Loop currently displays the blogposts in ascending order of creation. How can I reverse the order of displaying them? Is there a reverse function? If yes, how can it be implemented in this context? I'm using woods cms. https://github.com/studiomoniker/woods
Upvotes: 1
Views: 1832
Reputation: 59
This helped.
for child in page.get('/posts').children.reverse()
Upvotes: 2
Reputation: 516
You could use while to iterate over the posts backwards:
ul.blogpostGrid
- var posts = page.get('/posts').children;
- var postIndex = posts.length;
while postIndex >= 0
a(href=posts[postIndex--]): li.col.span_1_of_4
h2 #{posts[postIndex--].title}
div.imgThumb(style='background-image: url(#{posts[postIndex--].url}thumb.jpg);')
p #{posts[postIndex--].excerpt}
Upvotes: 0