Skip to content

How to render a .md file from a .erb template? #673

Answered by jaredcwhite
joemasilotti asked this question in Q&A
Discussion options

You must be logged in to vote

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:

<%= 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…)

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@jaredcwhite
Comment options

@joemasilotti
Comment options

@jaredcwhite
Comment options

@jaredcwhite
Comment options

@joemasilotti
Comment options

Answer selected by joemasilotti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants