Reputation: 393
I'm trying to grab a file specified in the front matter of Jekyll page and and then render markdown in my template.
This just worked when there was only one key in the yaml, but I changed it to a loop and now I can't get it to render the markdown. It just spits out the values, and doesn't actually markdownify them.
My yaml looks like this:
additional_sidebar:
- editorial-extra.md
- editorial-extra-2.md
My Liquid looks like this:
{% for sidebar in page.additional_sidebar %}
{% capture sidebar %}{% include {{ sidebar }} %}{% endcapture %}
<section class="aside">
{{ sidebar | markdownify }}
</section>
{% endfor %}
The result is that it just spits out the values, instead of rending the markdown:
editorial-extra.md editorial-extra-2.md
For reference, this was my original, working code:
yaml:
additional_sidebar: editorial-extra.md
Liquid:
{% if page.additional_sidebar %}
{% capture additional_sidebar %}{% include {{ page.additional_sidebar }} %}{% endcapture %}
<section class="aside aside-scroll fixedsticky">
{{ additional_sidebar | markdownify }}
</section>
{% endif %}
Upvotes: 2
Views: 1460
Reputation: 52829
You have a race condition in your liquid code. You use the sidebar var in the loop and in the capture. Just change the sidebar for sidebarmd in the capture.
{% for sidebar in page.additional_sidebar %}
{% capture sidebarmd %}{% include {{ sidebar }} %}{% endcapture %}
<section class="aside">
{{ sidebarmd | markdownify }}
</section>
{% endfor %}
Upvotes: 4