Open klaronix opened 9 years ago
Yeah that sounds like a reasonable idea.
I found that this works:
{{#each page.posts.data as |post|}}
<h2>{{post.title}}</h2>
{{/each}
but I expected to be able to do this instead, which is cleaner and reflects how the EJS documentation says this should work:
{{#each page.posts as |post|}}
<h2>{{post.title}}</h2>
{{/each}
Why does the HBS Hexo plugin use this construct for the page.posts object?
{
"data": [
// array of posts
],
"length": 1
}
Just for curiosity: how do you iterate over page.posts/site.posts/tags, ...? After trying a lot of different ways, I ended up with two possibilities:
This works if you don't want to limit posts; you will iterate over all of them (can't change ordering either). Other possiblity: create a helper which converts query objects to an array:
or
I would suggest adding this "to_array" as a standard helper. Any other possibilities?