Template Actions in Markdown files?

(Annika Backstrom) #1

I’m trying Caddy for the first time, and attempting to use Template Actions within Markdown files rendered with the markdown middleware. I believe the Markdown is rendered before it’s parsed for template tags, so a string like {{Include "other.md"}} is converted to {{.Include "other.md"}}, breaking the template tag and generating a 500 error. Template Actions without quotes (e.g. {{.IP}}) work as expected.

Is there a supported way to use template tags in Markdown files?

Sample Caddyfile:


root www
templates / .md

Sample Markdown file:

{{.Include "other.md"}}


13/Feb/2018:15:41:46 +0000 [ERROR 500 /test.md] template: test.md:9: unexpected “&” in operand

(Matt Holt) #2

Hmm, rather than combining those two, since they kind of step on each other a bit, use just one or the other. You can execute templates in markdown by specifying your own page templates, and you can execute markdown in templates by using the {{.Markdown}} template action.

(Annika Backstrom) #3

Thanks @matt! I think either option loses some of the functionality I was hoping for, but overall the markdown middleware provides more of what I wanted. I’ll stick with that and live with the lack of Template Actions in the page body.

(system) #4

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.