11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
17.33k stars 495 forks source link

Error `TemplateContentUnrenderedTemplateError ` in incremental mode #3410

Open monochromer opened 3 months ago

monochromer commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

Successfully reproduced using provided test case, thank you!

zachleat commented 3 months ago

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

julientaq commented 1 month ago

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 commented 1 month ago

Confirm. This bug is reproduced in 3.0.0.