Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

SSR: Experiment with WP_HTML_Tag_Processor #125

Closed
wants to merge 29 commits into from

Conversation

ockham
Copy link
Collaborator

@ockham ockham commented Dec 22, 2022

Trimmed-down version of #118, based directly on the main-wp-directives-plugin branch.

  • Adds PHP unit test infrastructure and CI.
  • Adds WP_HTML_Tag_Processor files from Gutenberg trunk (i.e. everything from GB's lib/experimental/html/ is copied to src/html/). Now relies on the GB plugin to be installed and active, and uses its files directly.

We then add individual directives into src/directives/, and their corresponding unit tests into phpunit/directives/.

This should allow us to adopt a test-driven development approach, as we implement all missing directives, and to identify what other features we need in WP_HTML_Tag_Processor (also see #120).

✅ - Implemented
🟡 - Waiting for an upcoming Gutenberg release to include a missing feature
❌ - Blocked by missing feature in WP_HTML_Tag_Processor

Name Attribute directive Tag directive Missing feature
wp-context
wp-show Wrapping content inside HTML tags with extra tags. E.g. get_content_inside_balanced_tags() from WordPress/gutenberg#46345, and a matching set_content_inside_balanced_tags() (see WordPress/gutenberg#47036).
wp-bind N/A get_attribute_names_with_prefix(); landed in GB 15.0
wp-class N/A See wp-bind.
wp-style N/A See wp-bind. Furthermore, see WordPress/gutenberg#46887. (The latter isn't a blocker, though.)
wp-text Replace content between HTML tags. See wp-show.
wp-for / wp-each
wp-html Replace content between HTML tags. See wp-show.
wp-slot & wp-fill

Testing Instructions

Note that this PR currently requires at least GB v14.9. You might have to npm run wp-env destroy and restart it in order to update your GB version.

In addition, this PR currently uses get_attribute_names_with_prefix from WordPress/gutenberg#46840, which hasn't been merged into GB yet.

To make it available locally, either add a .wp-env.override.json and point it to your local GB directory (with the required branch checked out), or apply the patch to your ~/.wp-env/<yourdirectory>/gutenberg/ folder.

src/directives/wp-show.php Outdated Show resolved Hide resolved
@ockham
Copy link
Collaborator Author

ockham commented Jan 26, 2023

I'll close this PR, since most of its code has now been merged into the main-wp-directives-plugin branch (per #133) 🎉
For wp-show (which is still blocked), I've opened #141.

I'll carry the status table from the PR description over to the tracking issue (#120), which will then serve as the only source of truth.

@ockham ockham closed this Jan 26, 2023
@ockham ockham deleted the try/ssr-directives branch January 26, 2023 14:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant