Skip to content

what does post and data contain? is "filename" available? #2284

Answered by pdehaan
ahillio asked this question in Q&A
Discussion options

You must be logged in to vote

Buckle up, it's about to get educational up in here!

First let's walk through the output of your attempts so far and see if we have roughly the same results. You said the first attempt "didn't work", but never mentioned what the output was.
I tried my best to recreate your example locally so hopefully our code is somewhat close:

<h2>OPTION 1</h2>
{% assign posts = collections.how-are-you %}
{%- for post in posts -%}
<div>{{ post }}</div>
{%- endfor -%}

When I run this, I get the following:

<h2>OPTION 1</h2>
<div>[object Object]</div>
<div>[object Object]</div>
<div>[object Object]</div>
<div>[object Object]</div>

That is also the same output I see if I try logging {{ post.data }}:

<h2>OPT…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@pdehaan
Comment options

pdehaan Mar 22, 2022
Collaborator

@ahillio
Comment options

@pdehaan
Comment options

pdehaan Mar 23, 2022
Collaborator

@ahillio
Comment options

@pdehaan
Comment options

pdehaan Mar 23, 2022
Collaborator

Answer selected by ahillio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants