-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Open
Labels
[Feature] Interactivity APIAPI to add frontend interactivity to blocks.API to add frontend interactivity to blocks.[Type] EnhancementA suggestion for improvement.A suggestion for improvement.
Description
There is no way to render HTML using Directive?
When we use Interactivity API for block and if we want to display html content inside data-wp-each
we can't display our html contnet using any directive.
In the below sample code, I want to render html for class="step-text"
Sample code:
<template data-wp-each--step="context.steps">
<div class="step-card" data-wp-bind--data-index="context.step.index" data-wp-class--show="state.showStep">
<div data-wp-text="context.step.step"></div>
<div class="step-text" data-wp-text="context.step.description"></div>
</div>
</template>
What is your proposed solution?
We should have directive like data-wp-html
Metadata
Metadata
Assignees
Labels
[Feature] Interactivity APIAPI to add frontend interactivity to blocks.API to add frontend interactivity to blocks.[Type] EnhancementA suggestion for improvement.A suggestion for improvement.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Bhumit9416 commentedon Jul 17, 2025
Hi! 👋
I totally agree with this proposal — the current data-wp-text directive only renders plain text, which escapes HTML, making it difficult to display rich formatted content such as bold text, links, or custom markup inside data-wp-each loops.
A data-wp-html directive (or similar) would solve this gap nicely. Some thoughts:
It should safely insert trusted HTML into the DOM, like innerHTML, but within a sandboxed or scoped context.
Perhaps it could follow a similar implementation pattern as dangerouslySetInnerHTML in React — with clear warnings or escapes when necessary.
It could optionally sanitize or allow developers to opt into raw HTML rendering (with a warning if needed).
I'd love to try a prototype or explore how this could be added to the existing directive system.
Let me know if this enhancement is being planned — I'd be happy to help or test a PR for it.