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

Consistency between example files and handbook #20

Closed
Lageeek opened this issue Mar 10, 2018 · 0 comments · Fixed by WordPress/gutenberg#14584
Closed

Consistency between example files and handbook #20

Lageeek opened this issue Mar 10, 2018 · 0 comments · Fixed by WordPress/gutenberg#14584

Comments

@Lageeek
Copy link

Lageeek commented Mar 10, 2018

In the Gutenberg handbook is a tutorial "Creating Block Types". This seems to be for very beginners. There is stated:

To follow along with this tutorial, you can download the accompanying WordPress plugin which includes all of the examples for you to try on your own site.

The plugin for download is this one with these examples: /gutenberg-examples

Comparing source codes you'll find that they are not identical.
For example chapter one "writing your first block type"

--- enqueuing Block scripts ---
Handbook (hb) wp_register_script(
Gutenberg-examples (ge) 01-baisc wp_enqueue_script(

(hb) register_block_type(
(ge) blocks.registerBlockType(

(hb) missing i18n

(hb) use of prefix wp. var el = wp.element.createElement
(ge) var el = element.createElement;

(hb) missing window.wp.blocks, window.wp.i18n, window.wp.element

(hb) missing filemtime( plugin_dir_path( __FILE__ ) . 'block.js' )

And general questions to understand the source code:

(ge) path = gutenberg-examples/01-basic/block.js
Why the block_type is named example-01-basic from blocks.registerBlockType( 'gutenberg-examples/example-01-basic', {

What does this mean? step 1 (from the editor). from 'Hello World, step 1 (from the editor).'
The same in (hb) (Step 1) from title: 'Hello World (Step 1)',

The namings are totally different:
(hb) wp_register_script( 'gutenberg-boilerplate-es5-step01', plugins_url( 'step-01/block.js', __FILE__ ), array( 'wp-blocks', 'wp-element' )

(ge) wp_enqueue_script( 'gutenberg-examples-01', plugins_url( 'block.js', __FILE__ ), array( 'wp-blocks', 'wp-i18n', 'wp-element' ), filemtime( plugin_dir_path( __FILE__ ) . 'block.js' )


If you look in the other examples you'll find more inconsistency

As learning references these examples are not particularly helpful, on the contrary, they are confusing - especially for beginners.

What is wrong, what should I use, why there is a prefix wp. there not, why there it is blocks.register... and there register?... and so on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant