beapi / gutenberg-serializer
Serialize gutenberg blocks array to a string
Installs: 4 486
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 5
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
- ext-json: *
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^0.6.2
- jakub-onderka/php-parallel-lint: ^1.0
- phpcompatibility/php-compatibility: ^9.3
- phpro/grumphp-shim: ^0.17.2
- phpunit/phpunit: ^8.5
- sensiolabs/security-checker: ^6.0
- squizlabs/php_codesniffer: ^3.5
- vimeo/psalm: ^3.8
- wp-coding-standards/wpcs: ^2.2
This package is auto-updated.
Last update: 2024-10-29 05:29:13 UTC
README
Package to transform Gutenberg block array to a Gutenberg firendly string
Purpose
This package allows you to use a block array from "parse_blocs" for example, and serialize it into Gutenberg compatible content. This can be used to migrate content from blocs or programmatically generate content for Gutenberg. The library supports innerBlocs.
Example
$bloc = [ [ 'blockName' => 'core/paragraph', 'attrs' => [ 'id' => 4 ], 'innerBlocks' => [], 'innerHTML' => ' <p>This is a content</p> ', 'innerContent' => [ 0 => ' <p>This is a content</p> ', ], ] ]; $content = BlocksSerializer::from_array( $bloc );
Will become :
<!-- wp:paragraph {"id":"4"} -->
<p>This is a content</p>
<!-- /wp:paragraph -->
Commands
You have commands into the project :
composer cs
: Check the coding standardscomposer cbf
: Beautify automatically all the files of the projectcomposer test
: Launch the testscomposer psalm
: Launch psalm on the files