Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Adds clarifications and clears up inaccuracies #46283

Merged

Conversation

mburridge
Copy link
Contributor

What?

Fixes inaccurate reference to the name being registered in the PHP file and corrects it to reference the name property in theme.json.
Fixes inaccurate implication that setAttributes gets passed to the save function.
Adds some clarifications around both items.

Why?

To remove inaccurate/misleading information and provide clarification.

@mburridge mburridge added [Type] Developer Documentation Documentation for developers Developer Experience Ideas about improving block and theme developer experience labels Dec 2, 2022
Copy link
Contributor

@alexstine alexstine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mburridge Thanks for the PR. One edit.

@@ -29,15 +29,15 @@ registerBlockType( metadata.name, {
} );
```

The first parameter in the **registerBlockType** function is the block name, this should match exactly to the name registered in the PHP file.
The first parameter in the **registerBlockType** function is the block name, this should match exactly to the `name` property in the `block.json` file. By importing the metadata from `block.json` and referencing the `name` property in the first parameter we ensure that they will match, and continue to match even if the name is subsecquently changed in `block.json`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The first parameter in the **registerBlockType** function is the block name, this should match exactly to the `name` property in the `block.json` file. By importing the metadata from `block.json` and referencing the `name` property in the first parameter we ensure that they will match, and continue to match even if the name is subsecquently changed in `block.json`.
The first parameter in the **registerBlockType** function is the block name, this should match exactly to the `name` property in the `block.json` file. By importing the metadata from `block.json` and referencing the `name` property in the first parameter we ensure that they will match, and continue to match even if the name is subsequently changed in `block.json`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks @alexstine

Copy link
Contributor

@ryanwelcher ryanwelcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together @mburridge. I made one small change to add a comma, but otherwise LGTM!

docs/getting-started/create-block/attributes.md Outdated Show resolved Hide resolved
Co-authored-by: Ryan Welcher <me@ryanwelcher.com>
@alexstine
Copy link
Contributor

This one good to go now? If so, feel free to re-run the pesky failing tests and merge. Flaky tests.

@mburridge mburridge merged commit b333d1d into WordPress:trunk Dec 9, 2022
@github-actions github-actions bot added this to the Gutenberg 14.8 milestone Dec 9, 2022
@mburridge mburridge deleted the docs/update-create-block-tutorial branch December 9, 2022 22:33
@ryanwelcher ryanwelcher changed the title Adds clarifications and clears up inaccuracies Documentation: Adds clarifications and clears up inaccuracies Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer Experience Ideas about improving block and theme developer experience [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants