From fc05baa76d80d78f053e42b991a4e99517f3f3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B8ller?= Date: Thu, 29 Feb 2024 10:50:57 +0100 Subject: [PATCH] Fixed an issue with getTemplate --- src/Block.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Block.php b/src/Block.php index 172f6388..b57ef651 100644 --- a/src/Block.php +++ b/src/Block.php @@ -299,10 +299,15 @@ public function getInlineStyle(): string * Returns the block template. * * @param array $template - * @return \Illuminate\Support\Collection + * @return string|\Illuminate\Support\Collection */ public function getTemplate($template = []) { + + if (is_string($template)) { + return $template; + } + return collect($template)->map(function ($value, $key) { if (is_array($value) && Arr::has($value, 'innerBlocks')) { $innerBlocks = collect($value['innerBlocks'])->map(function ($innerBlock) { @@ -313,7 +318,7 @@ public function getTemplate($template = []) } return [$key, $value]; - })->values(); + })->values()->toJson(); } /** @@ -461,7 +466,7 @@ public function render($block, $content = '', $preview = false, $post_id = 0, $w ])->filter()->implode(' '); $this->style = $this->getStyle(); - $this->template = $this->getTemplate($this->template)->toJson(); + $this->template = $this->getTemplate($this->template); $this->inlineStyle = $this->getInlineStyle();