-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Description
Describe the bug
Adding plain HTML comments (<!-- -->) inside block theme pattern files
(patterns/*.php) or template files (templates/*.html) causes the
"This block contains unexpected or invalid content" error in the Site Editor.
When this error occurs, the affected blocks cannot be edited in the visual editor.
Step-by-step reproduction instructions
To Reproduce
-
Create a block theme with a
patterns/ortemplates/directory -
Add a plain HTML comment inside a pattern or template file, e.g.:
Page not found
-
Open the
template in the Site Editor
4. The block displays "This block contains unexpected or invalid content"
and cannot be edited in the visual editor
Screenshots
(screenshot attached)
Expected behavior
Plain HTML comments that do not match the block delimiter syntax
(<!-- wp:blockname -->) should be ignored by the block parser
and should not cause block validation errors.
Is there a recommended way to add plain comments inside pattern or
template files without triggering this error?
Screenshots, screen recording, code snippet
No response
Environment info
Environment
- WordPress version: 6.9 - 7.0beta5
- Browser: Chrome / Edge
Related issue
- Inline HTML comments are removed when a Block is edited #13318 Inline HTML comments are removed when a Block is edited
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure