Skip to content

Commit

Permalink
[Create Block] Add support for the example property and add template …
Browse files Browse the repository at this point in the history
…defaults. (WordPress#52803)

* Add support for the example property and add template defaults.

* Update changelog

I also included the change of the last version that we forgot.

* Fix small typo

---------

Co-authored-by: Luis Herranz <[email protected]>
  • Loading branch information
ryanwelcher and luisherranz authored Jul 22, 2023
1 parent d7fdabf commit 26bf6db
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/create-block/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

## Unreleased

### Enhancement

- Add support for the `example` property and add it to the default template ([#52803](https://github.com/WordPress/gutenberg/pull/52803)).

## 4.22.0 (2023-07-20)

### Enhancement

- Add support for the `viewScript` property ([#52612](https://github.com/WordPress/gutenberg/pull/52612)).

## 4.21.0 (2023-07-05)

## 4.20.0 (2023-06-23)
Expand Down
2 changes: 2 additions & 0 deletions packages/create-block/lib/init-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async function initBlockJSON( {
render,
viewScript,
customBlockJSON,
example,
} ) {
info( '' );
info( 'Creating a "block.json" file.' );
Expand All @@ -53,6 +54,7 @@ async function initBlockJSON( {
category,
icon: dashicon,
description,
example,
attributes,
supports,
textdomain,
Expand Down
2 changes: 2 additions & 0 deletions packages/create-block/lib/scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module.exports = async (
variantVars,
customPackageJSON,
customBlockJSON,
example,
}
) => {
slug = slug.toLowerCase();
Expand Down Expand Up @@ -107,6 +108,7 @@ module.exports = async (
viewScript,
customPackageJSON,
customBlockJSON,
example,
...variantVars,
};

Expand Down
2 changes: 2 additions & 0 deletions packages/create-block/lib/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const predefinedPluginTemplates = {
editorStyle: null,
style: null,
viewScript: 'file:./view.js',
example: {},
},
templatesPath: join( __dirname, 'templates', 'es5' ),
variants: {
Expand All @@ -55,6 +56,7 @@ const predefinedPluginTemplates = {
html: false,
},
viewScript: 'file:./view.js',
example: {},
},
variants: {
static: {},
Expand Down

0 comments on commit 26bf6db

Please sign in to comment.