Skip to content

Some html content of .njk file that is included in .md file is rendered as raw text #1971

@kirillunlimited

Description

@kirillunlimited

I have a list that is represented as separate files:
list/element1.md

---
title: Element 1
---

list/element2.md

---
title: Element 2
---

list/list.json

{
  "tags": "list"
}

I would like to output them as collection.
I iterate over them in the separate .njk file (this is an example, the real layout is a little bit more complicated):
inlcudes/list.njk

<ol>
  {% for element in collections.list %}
    <li>
        {{element.data.title}}
    </li>
  {% endfor %}
</ol>

Then I include this .njk file in my final .md page file.
pages/home.md

---
layout: page.njk
title: Home
templateEngineOverride: md,njk
---
# Home page
{% include 'list.njk' %}

The problem is that content inside for-loop is wrapped inside pre tag:

<h1>Home page</h1>
<ol>
<pre><code>&lt;li&gt;
    Element 2
&lt;/li&gt;
&lt;li&gt;
    Element 1
&lt;/li&gt;
</code></pre>
</ol>

I tried different combinations of values in templateEngineOverride parameter but none worked.
Yes, I can use .njk instead .md as page file extension, but I need to be able to use markdown in it. Also I can't output list directly in .md file as I want to put this list in another pages with include.

Please help. Are there any solutions?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions