Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue with getTemplate #209

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixed an issue with getTemplate
djaevlen committed Feb 29, 2024
commit fc05baa76d80d78f053e42b991a4e99517f3f3b7
11 changes: 8 additions & 3 deletions src/Block.php
Original file line number Diff line number Diff line change
@@ -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();