Support variable interpolation inside code blocks #4248
Replies: 1 comment
-
|
+1 on this! We ran into the same limitation at Fingerprint. Our documentation injects dynamic values from the user session (like their API key) into code examples, so readers see ready-to-use snippets personalized to their account. Our current workaround is using the <CodeBlock
language="javascript"
filename="NPM"
children={`
import Fingerprint from '@fingerprint/agent'
const fp = Fingerprint.start({
apiKey: '${user.primaryBrowserToken ?? "YOUR_PUBLIC_API_KEY"}',
})
`}
/>This works for rendering, but it has a significant maintenance problem: the Mintlify web editor doesn't understand this pattern. When someone edits the page through the web editor, the Native support for variable interpolation inside fenced code blocks would let us drop the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
I'm writing SDK documentation where version numbers need to be kept in sync across multiple pages. I'm using exported constants like this:
These constants work perfectly in MDX components such as
<Info>blocks:However, they are not resolved inside fenced code blocks — the variable name is rendered as a literal string instead of being replaced with the actual value.
Expected Behavior
I'd like to be able to reference exported constants inside code blocks, for example:
This should render as:
dependencies { implementation "com.example:my-sdk:2.0.0" }Why This Matters
For SDK documentation, version numbers appear in many code examples across multiple pages. Without variable interpolation in code blocks, every version bump requires manually updating all code examples — which is error-prone and tedious. This feature would make docs significantly easier to maintain and keep consistent.
Additional Context
I've reviewed the Reusable Snippets documentation but couldn't find a workaround for this use case. Mintlify support confirmed this is not currently supported and suggested submitting a feature request here.
Beta Was this translation helpful? Give feedback.
All reactions