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

Template function to include file without parsing that file as a template (ie. includeRaw) #5552

Closed
asyncmeow opened this issue May 22, 2023 · 3 comments · Fixed by #5553
Closed
Labels
feature ⚙️ New feature or request

Comments

@asyncmeow
Copy link
Contributor

I'm trying to create a simple markdown-based blog using Caddy. One issue I'm running in to though, is when I try to include the markdown file to splitFrontMatter on it (or later to render it), I run into an issue where the contents of the markdown file are parsed as a template.

A possible workaround for this is to set between on the templates directive as linked here, but, again, this is more of a workaround than a real fix. Specifically, this fix wouldn't work in the case where you're trying to document how you created the blog, in a blog post, since you'd need to show the templates in that post!

What I'm proposing is a includeRaw template function, where the contents of the file are read and returned, but without parsing the given file as a template, to prevent issues like the infinite recursion I was hitting when trying to use include in my use case.

@mholt
Copy link
Member

mholt commented May 22, 2023

So my understanding is you want to escape literal template delimiters?

You can do something like this:

{{"{{"}}
{{"}}"}}

Funky, I know, but it works. 🤷‍♂️

@asyncmeow
Copy link
Contributor Author

The idea was that I could avoid having to do weird escaping on the source markdown file, such that it would render the same as it would in any other markdown renderer.

@francislavoie francislavoie added the feature ⚙️ New feature or request label May 22, 2023
@mholt
Copy link
Member

mholt commented May 22, 2023

Gotcha. Okay, yeah, an includeRaw might be a good way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants