Repository navigation
Conversation
Components without a recipe get their markup from React: the build renders them with placeholders for their content and free-form props, once with the defaults and once per variant value, and stores the default render plus what each value changes.
When a component has no template, gutenberg_get_ui_component() applies the stored changes to the base render with WP_HTML_Tag_Processor and fills in the placeholders, escaped for their context. Button drops its recipe and template, and passes the same parity tests.
…ponents-php-build-markup
…ponents-php-build-markup
🤖 PR meta 🤖📦 Bundle sizeSize Change: 0 B Total Size: 8.64 MB
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Page List converts to Navigation Links with entity bindings in
|
This was referenced Oct 27, 2026
…ponents-php-build-markup # Conflicts: # lib/experimental/ui-components/components/button.php
…ponents-php-build-markup
…ponents-php-build-markup # Conflicts: # lib/experimental/ui-components/components/button.php # lib/experimental/ui-components/load.php # packages/ui/bin/build-php.mjs # packages/ui/php/button/component.json
…ponents-php-build-markup
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
See #84036. Builds on #85756.
This switches Button to take its markup from React at build time, instead of the recipe and PHP template from #85756. The API, the preview page and the parity tests stay the same, so it's easy to compare the two on the same component.
Why?
#85756 renders Button from a recipe and a small template, which is simple but kept in sync with React by hand. This PR explores the other side of that trade-off. Here React stays the only source of the markup, and nothing is written by hand per component beyond its props. Having both on top of the same base, passing the same tests, makes it easier to compare.
It's a lighter version of the approach first explored in #84714: the markup is stored as a base render plus changes (from #84905), and checking every combination is left to the shared parity tests.
How?
class), once with the default props and once per variant value. It stores the default render plus what each value changes: classes, attributes and inline styles, per tag. For Button that's one base render and a handful of changes.gutenberg_get_ui_component()starts from the base render, applies the changes for the given props withWP_HTML_Tag_Processor, and fills in the placeholders.__wpuislot_content__text__,__wpuislot_class__attr_class__), and PHP escapes it for that context. URL attributes go throughesc_url(). Values are escaped the way React does, without reusing existing entities. This is a small, custom version of the context-aware templating explored in wordpress-develop#5949: if that lands in core, the placeholder filling here could be replaced with it.Trade-offs, compared with the recipe
With a recipe (#85756):
With markup from React (this PR):
Measurements
I measured how this scales on a few components with different shapes: class variants (Button, IconButton), one prop with many values (Badge, Text), props that interact (Link), structure that changes per variant (Notice), and many props with inline styles (Stack, probably the worst case for combinations).
From these measurements:
So, from what I measured, the trade-off might be less about build time or output size, and more about where the complexity lives. Shared code in this approach, or a recipe and a small template per component in the recipe approach. It'd be worth checking with more components before drawing conclusions.
Limits
&) shows as written, whileesc_html()in the template keeps it as an entity. Both match React in the parity tests, which compare the decoded text.Testing Instructions
npm run build.packages/ui/build-php/manifest.json: Button now has amarkupentry with the base render and the changes, instead of a recipe.Automated checks, the same as #85756:
npm run test:unit:php:base -- --filter Gutenberg_UI_Components_TestUse of AI Tools
I used Claude Code to help prototype and write parts of this code. I reviewed and tested all of it.