Is there a way to dynamically render partial file content? #494
Replies: 1 comment
-
I think I'd need to see a bit more of your setup in order to fully understand what you are trying to accomplish. But generally, partials are evaluated during the transform step — in order to be able to convert a partial into the equivalent render tree you would need to provide the full content of the partial in the That said, there's not really any special casing for partials in Markdoc itself — it's basically just a tag that renders a specific way. If you need to override the behavior of partials so that you can dynamically render them under different conditions, you can just override the tag with your own definition or create a separate tag that has the behavior you want. It can be helpful to look at how the parrtial tag itself is defined in Markdoc: https://github.com/markdoc/markdoc/blob/main/src/tags/partial.ts You can copy/paste that schema definition and modify it as needed for your project. |
Beta Was this translation helpful? Give feedback.
-
I have a requirement where I am rendering a react component based on an object. The object may have description as a markdoc tag.
{ "name": "temp", "description": "{% partial file='temp.md' /%}"}
. I tried theparse
,transform
,renderes
approach but on validating I'm getting error as:Partial temp.md not found. The 'file' attribute must be set in config.partials
Beta Was this translation helpful? Give feedback.
All reactions