Skip to content

2.4.6: Inconsistent template rendering when having nested includes #4423

@triole

Description

@triole

First off thanks for this wonderful piece of software. Caddy is great.

Problem Description
I use caddy for some pretty complex markdown templating with nested includes. With caddy 2.4.5 everything was fine but with the latest version 2.4.6 rendering templates seems pretty inconsistent. Caddy renders different pages between page reloads. Sometimes the result looks good, sometimes the markdown file is put plain as it is into the final html leading to something like this:

<!DOCTYPE html>
<html>

<head>
</head>

<body>
    ---
title: My Title
tags:
    - tag1
    - tag2
    - tag3
---
# What a wonderful heading

And a lot of text...

<h1><p>My Title</p>
</h1>
<h1 id="what-a-wonderful-heading">What a wonderful heading</h1>
<p>And a lot of text...</p>


</body>

</html>

Here is a simple version of my setup

Caddyfile

:7777 {
	file_server
	templates
}

index.html

<!DOCTYPE html>
<html>

<head>
</head>

<body>
    {{include "incl.html"}}
</body>

</html>

incl.html

{{$content := "markdown.md"}}
{{$p := include $content | splitFrontMatter}}
<h1>{{markdown $p.Meta.title}}</h1>
{{markdown $p.Body}}

markdown.md

---
title: My Title
tags:
    - tag1
    - tag2
    - tag3
---
# What a wonderful heading

And a lot of text...

How to reproduce
Try loading the page several times (i.e. curl http://localhost:7777) and look into what you get. The different versions of output seem to be pretty evenly distributed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐞Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions