Skip to content

Commit

Permalink
Fixed an issue with getTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
djaevlen committed Feb 29, 2024
1 parent 21f654d commit fc05baa
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -313,7 +318,7 @@ public function getTemplate($template = [])
}

return [$key, $value];
})->values();
})->values()->toJson();
}

/**
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit fc05baa

Please sign in to comment.