Open leogzyl opened 1 year ago
I've reproduced your steps down get the error to show, and that a whitespace change to the template triggers a successful build. Can you elaborate on what you mean by
Removing label in the model file makes everything work.
Which label? Thank you for the report.
I'm actually experiencing something similar I think in another site.
I'm not sure what's causing this atm, or if it's always been present or somehow came about because of a change in behavior of a dependency.
It's worth noting that your report is a failure of jinja to render a string type, whereas mine in another project is a failure to render a markdown type, but you have a markdown type succeeding on the first pass.
This feels like something non-deterministic, yet once a page is built, it's kind of stuck that way until we trick the page into being built again.
This sort of seems deterministic. For me, it fails on my other site every time I lektor clean --yes; lektor b
, but succeeds every time I lektor clean --yes; lektor s
. But in the quickstart project I seem to have the opposite behavior, where build
ing first is the successful one, but going straight to server
produces the failing render.
I've reproduced your steps down get the error to show, and that a whitespace change to the template triggers a successful build. Can you elaborate on what you mean by
Removing label in the model file makes everything work.
Which label? Thank you for the report.
I'm actually experiencing something similar I think in another site.
I'm not sure what's causing this atm, or if it's always been present or somehow came about because of a change in behavior of a dependency.
I mean the "label" line on the Page model file (line 3 in the last code snippet in my original comment). To be completely honest, I'm not 100% sure that causes the issue... or simply triggers a rebuild somehow.
I also played around with cleaning and rebuilding and managed to get it to work at times, but never got to the bottom of it, hence the vague bug report.
Anyway, glad to contribute, and thanks for looking into it!
I have a fix for this. I'll merge it in and publish a fixed version in a day or two.
I've set a breakpoint in JinjaContentPlugin##render_as_jinja
and I see my test field being rendered properly (in my case, the default author
field in the default Blog
sample site). At the end of on_process_template_context
, the context
object is correctly populated with a rendered version of all the fields. However, despite this, Lektor goes on to use the original field values, as if the context
object were never modified.
Perhaps Lektor itself is using a different copy of this object? I can debug further but I'd like to hear what @nixjdm found, before expending a bunch of effort. Can I help get the patch over the finish line?
Using the basic blog from
lektor quickstart
, I get strange behavior with some fields.Take the start page,
page.html
for example:When running
lektor serve
...This markdown:
Renders like this:![Screenshot from 2023-01-14 17-07-02](https://user-images.githubusercontent.com/4330426/212482150-345c7c31-2551-4590-85cc-3df0a4ad46a9.png)
If I make a trivial whitespace change to![Screenshot from 2023-01-14 17-10-49](https://user-images.githubusercontent.com/4330426/212482290-bb0f8dd8-6ac8-4e2c-94eb-a58db932a425.png)
page.html
to force the watcher to do a refresh, everything works:Here's the Page model:
Removing
label
in the model file makes everything work.