Skip to content

feat(renderer): interpolate placeholders in bound props - #516

Open
adamdehaven wants to merge 2 commits into
nuxt-content:mainfrom
adamdehaven:feat/dynamic-prop-string-concatination
Open

adamdehaven wants to merge 2 commits into
nuxt-content:mainfrom
adamdehaven:feat/dynamic-prop-string-concatination

Conversation

@adamdehaven

@adamdehaven adamdehaven commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

: and v-bind: string props can now mix fixed text with {{ }} placeholders:

:a[Docs]{:href="/docs/{{ doc.slug }}/overview"}
---
api:
  id: "9b3dc8fc-f3a3-4796-bbbc-400985eafe74"
  slug: "getting-started"
---

::a
---
:href: https://example.com/apis/{{ $doc.api.id }}
---
Link with API ID
::

::a
---
:href: https://example.com/apis/{{ api.slug }}
---
Link with API slug
::

Placeholders resolve against the same data as text bindings. The result is always a string.

Resolves #515

How it works

  • New src/runtime/utils/template.ts. MDCRenderer.vue calls it from propsToDataRxBind.
  • Lookups use own properties only. Functions never run.
  • A linear scanner with limits (4096 characters, 16 placeholders, 256 per placeholder).
  • The assembled value is checked with validateProp and the unsafe link prefixes. An unsafe prop is removed with a warning that names the prop only.
  • isAnchorLinkAllowed no longer throws on malformed %. Link props treat it as unsafe.

Compatibility

These values keep the old behavior and are not interpolated:

  • Props without :, and key, ref, is and style.
  • Malformed templates and values over the limits.
  • JSON arrays and objects. The parser passes YAML arrays and objects as JSON.

A : prop that already held a well-formed {{ }} now interpolates.

Resolve placeholders such as path or default in bound string props
from document, ancestor and slot data. The result is always a string.

Placeholders read own properties only and never call functions. The
assembled value is checked before use, and an unsafe prop is removed
with a warning. Malformed templates and JSON values keep the old
behavior.

Also treat malformed percent encoding in link props as unsafe instead
of throwing.

Closes nuxt-content#515
@pkg-pr-new

pkg-pr-new Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxtjs/mdc@516

commit: a68872d

@adamdehaven

adamdehaven commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Also porting forward to Comark: comarkdown/comark#490

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot build a prop value from data with {{ }} in MDC components

1 participant