Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error TemplateContentUnrenderedTemplateError in incremental mode #3410

Open
monochromer opened this issue Aug 9, 2024 · 5 comments
Open
Labels

Comments

@monochromer
Copy link
Contributor

Operating system

MacOS Sonoma 14.6

Eleventy

3.0.0-beta.1

Describe the bug

In incremental mode i am getting an error TemplateContentUnrenderedTemplateError: Tried to use templateContent on unrendered template, when i try to edit file, that has content or templateContent getter:

<ul>
  {% for article in collections.articles %}
    <li>
      <article>
        {{ article.content | safe }}
      </article>
    </li>
  {% endfor %}
</ul>

Reproduction steps

  1. Go to stackblitz demo
  2. Run in incremental mode npm run dev:incremental
  3. Go to file feed.njk
  4. Change something
  5. Get error:
[11ty] File changed: src/feed.njk
[11ty] Problem writing Eleventy templates:
[11ty] 1. Having trouble rendering njk template ./src/feed.njk (via TemplateContentRenderError)
[11ty] 2. (./src/feed.njk)
[11ty]   TemplateContentUnrenderedTemplateError: Tried to use templateContent on unrendered template: ./src/articles/one/index.md (via Template render error)

Expected behavior

Behavior as in watch mode without incremental.

Reproduction URL

https://stackblitz.com/edit/stackblitz-starters-5wrmek?file=src%2Farticles%2Ffeed.njk

Screenshots

No response

@custom-dev-tools
Copy link

Experiencing same issue since upgrading to 3.0.0-beta.1
Only files that include *.content or *.templateContent fail when using --incremental
Removing --incremental from npx @11ty/eleventy --serve is the current workaround.

@zachleat zachleat added bug and removed needs-triage labels Sep 3, 2024
@zachleat zachleat added this to the Eleventy 3.0.0 milestone Sep 3, 2024
@zachleat
Copy link
Member

zachleat commented Sep 3, 2024

Successfully reproduced using provided test case, thank you!

@zachleat
Copy link
Member

zachleat commented Sep 4, 2024

Shipping with 3.0.0-beta.2 and 3.0.0-alpha.19

@julientaq
Copy link

I got the same error on 3.0.0

Trying to generate pages from a collection in --incremental mode.

I have this in a web.md file

---
eleventyImport:
  collections: ["allcontent"]
pagination:
  data: collections.bookcontent
  size: 1
  alias: pageitem
layout: "web/web-all.njk"
permalink: "/{{pageitem.data.collection}}/{{pageitem.data.id}}/index.html"
---

if i update web-all.njk, i get this error.

Tried to use templateContent on unrendered template

i have this line in the web-all.njk : 

 {{ pageitem.templateContent  | safe }} 

if i remove this line from the njk files, things get updated correctly (although it seems that the updated content isn’t updated, i need to stop/restart eleventy to see the changes).

@monochromer
Copy link
Contributor Author

Confirm. This bug is reproduced in 3.0.0.

@zachleat zachleat reopened this Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants