How to render a .md
file from a .erb
template?
#673
-
The docs on ERB + Markdown mention:
I'm trying to render # bridgetown.config.yml
template_engine: erb # src/index.erb
<%= render "about" %> # src/_partials/_about.md
---
template_engine: erb
---
* One
* Two But I keep getting the following error. Restarting the server doesn't help.
I see that it's looking for a Any ideas on what I'm doing wrong here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Ah, so partials don't actually support front matter or participate in the rendering pipeline for documents. They're literally just an extended bit of whichever template is in use (ERB, Serbea, etc.). I think what you'd want to do is creating something like a "snippets" collection, so you could place various markdown files in there. Then you could reference those from within a template rather than using <%= collections.snippets.resources.find { _1.data.slug == "about" }.content %> I'm writing that off the top of my head so if it doesn't work let me know. (You could also DRY that syntax up a bit with a new helper…) |
Beta Was this translation helpful? Give feedback.
Ah, so partials don't actually support front matter or participate in the rendering pipeline for documents. They're literally just an extended bit of whichever template is in use (ERB, Serbea, etc.).
I think what you'd want to do is creating something like a "snippets" collection, so you could place various markdown files in there. Then you could reference those from within a template rather than using
render
:I'm writing that off the top of my head so if it doesn't work let me know. (You could also DRY that syntax up a bit with a new helper…)