I am trying to use the for loop in Jekyll to render sample data. I can reference the markdown objects or whatever they are called directly, but when I use a for loop it doesn’t work. Here’s an example of the problem I am having:
markdown file with data:
tests:
test1:
number: 1 .
test2:
number: 2 .
test3:
number: 3 .
sessions.html:
<p>{{ page.tests.test1.number }}</p>
<p>{{ page.tests.test2.number }}</p>
<p>{{ page.tests.test3.number }}</p>
This outputs to:
<p>1</p>
<p>2</p>
<p>3</p>
If I do this instead:
{% for test in page.tests %}
<p>{{ test.number }}</p>
{% endfor %}
I get:
<p></p>
<p></p>
<p></p>
I can even do this:
{% for test in page.tests %}
<p>{{ test }}</p>
{% endfor %}
And get:
<p>test1{"number"=>1}</p>
<p>test2{"number"=>2}</p>
<p>test3{"number"=>3}</p>
Any idea what I am doing wrong?