[create-block] Refinements to the create-block-interactive-template package.#52801
Conversation
|
Size Change: +499 B (0%) Total Size: 1.44 MB
ℹ️ View Unchanged
|
luisherranz
left a comment
There was a problem hiding this comment.
LGTM!
I added a couple of questions below 🙂
|
|
||
| <div | ||
| <?php echo get_block_wrapper_attributes(); ?> | ||
| <?php echo wp_kses_data( get_block_wrapper_attributes() ); ?> |
There was a problem hiding this comment.
Are you sure this is needed? I've never seen it before, and none of the Core blocks seems to do it.
There was a problem hiding this comment.
There is some differing opinions on this. WPCS is trigger because all echo statements need to be escaped. That being said, I see that the default template in create-block is not using it. So I'll remove it for consistency.
| customBlockJSON: { | ||
| example: { | ||
| attributes: { | ||
| message: 'Example Interactive', | ||
| }, | ||
| }, | ||
| }, |
There was a problem hiding this comment.
So, out of curiosity, what is this example thing teaching the developer? How to add attributes?
There was a problem hiding this comment.
This does beg the question of the point of that inner attributes property. I don't think it's actually being used...
There was a problem hiding this comment.
Looks like by just having example defined, the preview appear. If we were actually using attributes, we'd need to add those as well. Change incoming.
There was a problem hiding this comment.
Ohhhh, nice.
I completely overlooked that example property until now 😄
|
I've moved the |
|
Flaky tests detected in 5629261. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5645662304
|


What?
This PR introduces some refinements to the template files to have the
exampleproperty defined in theblock.jsonfile instead of theindex.jsand to add some late escaping to the render.php file.Why?
It is better to contain as much as possible in the block.json file, especially if there are translations involved as those strings are automatically translated. The escaping items trigger various WPCS rules and make for a better developer experience.
Testing Instructions
cdinto thepackages/create-block-interactive-template create-block-interactive-templatenpx @wordpress/create-block@latest my-first-interactive-block --template ./my-first-interactive-blockand runnpx @wp-now/wp-now start]