beapi / gutenberg-serializer
将gutenberg块数组序列化为字符串
1.0.1
2020-10-18 09:09 UTC
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-08-29 05:01:00 UTC
README
将Gutenberg块数组转换为Gutenberg友好字符串的包
目的
此包允许您使用“parse_blocs”等示例中的块数组,并将其序列化为Gutenberg兼容的内容。这可以用于将内容从blocs迁移或程序化生成Gutenberg内容。该库支持innerBlocs。
示例
$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 );
将变成
<!-- wp:paragraph {"id":"4"} -->
<p>This is a content</p>
<!-- /wp:paragraph -->
命令
您在项目中可以使用以下命令
composer cs
: 检查编码标准composer cbf
: 自动美化项目中所有文件composer test
: 启动测试composer psalm
: 在文件上启动psalm