Description
Description
While working on #62092, I discovered that if a Core block's block.json
file contains a render
field that specifies a PHP file to render the block, that file is not copied to the build/
folder. This means that if a Core block were to use the render
field, it would break.
The same is not a problem for third-party blocks, as they are handled by code in wp-scripts
(added by #43917 and amended by #51162).
By contrast, Core blocks are built using a special Webpack config in; while there is code to copy their index.php
files to the build/
folder, there's none to handle render
files.
This is currently reflected by the fact that no Core blocks are using the render
field. However, it is somewhat confusing that they cannot use a documented API that is available for third-party blocks.
Step-by-step reproduction instructions
The following patch moves the Template Part block's render callback from its index.php
to a newly created render.php
, and adds a render
field to block.json
that points to that file.
Apply the patch and rebuild Gutenberg. Note that Template Part blocks no longer work on the frontend (they appear blank), and that the render.php
file is missing from build/block-library/blocks/template-part/
.
Screenshots, screen recording, code snippet
No response
Environment info
No response
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