diff --git a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockContainerTrait.php b/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockContainerTrait.php index f0244ef1ee7..25de5299d86 100644 --- a/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockContainerTrait.php +++ b/plugins/woocommerce/src/Internal/Admin/BlockTemplates/BlockContainerTrait.php @@ -219,9 +219,16 @@ trait BlockContainerTrait { $name = $this->get_name(); $attributes = $this->get_augmented_attributes(); - $children = implode( "\n", $arr ); + $children = implode( '', $arr ); - return '' !== $name ? get_comment_delimited_block_content( $name, $attributes, $children ) : $children; + $content = ''; + if ( 'core/column' === $name ) { + $content = '
'; + } elseif ( 'core/columns' === $name ) { + $content = ''; + } + + return '' !== $name ? get_comment_delimited_block_content( $name, $attributes, $content . $children ) : $children; } /** diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/BlockTest.php b/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/BlockTest.php index 86960bdf518..186a857ae2c 100644 --- a/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/BlockTest.php +++ b/plugins/woocommerce/tests/php/src/Internal/Admin/BlockTemplates/BlockTest.php @@ -713,6 +713,20 @@ class BlockTest extends WC_Unit_Test_Case { ) ); - $this->assertSame( '' . "\n" . '', $template->get_comment_delimited_template() ); + $columns = $block->add_block( + array( + 'id' => 'test-block-id-4', + 'blockName' => 'core/columns', + ) + ); + + $columns->add_block( + array( + 'id' => 'test-block-id-5', + 'blockName' => 'core/column', + ) + ); + + $this->assertSame( '', $template->get_comment_delimited_template() ); } }