-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
$template with multiple of same top level block #239
Comments
I believe the latter (wrapping) should work. #230 has some more info. |
Thanks for the quick reply @Log1x I could be wrong but I think that might just be for "InnerBlock" functionality. When wrapping top level blocks, the $block->template in the blade view spits out something like:
Opposed to when you have different block names:
|
ahhh I see. I will have to look into it when I get a moment but it might be an oversight |
I noticed this too. This syntax should be supported
|
Not sure my syntax above is correct after all. I tried both arrays and associative array syntax but nothing worked using the $template property of the block. I ended up doing the following:
|
Ran into the same issue. /**
* The block template.
*
* @var array
*/
public $template = [
[
'core/group',
[
'layout' => [
'type' => 'constrained',
],
],
[
[
'core/paragraph',
[
'align' => 'center',
'content' => 'I\'m a paragraph.',
],
[],
],
[
'core/separator',
[],
[],
],
],
],
];
/**
* Handle the block template.
*/
public function handleTemplate(array $template = []): Collection
{
return collect($template);
} |
This should be better in #267 – check the PR for examples. |
Hi there,
Hope all is well.
Is it possible to use the $template value with multiple of the same top level blocks?
I think the issue is that you specify a key of the name of the block and that overrides the previous one (vanilla php stuff etc).
For example, you will only end up with paragraph 3:
`
public $template = [
'core/paragraph' => ['placeholder' => "1"],
'core/paragraph' => ['placeholder' => "2"],
'core/paragraph' => ['placeholder' => "3"],
];
I also tried wrapping them but I don't think the handleTemplate supports this currently:
public $template = [
['core/paragraph' => ['placeholder' => "1"]],
['core/paragraph' => ['placeholder' => "2"]],
['core/paragraph' => ['placeholder' => "3"]],
];`
Not sure if I'm just missing something or if it could be supported at some time?
Thanks in advance!
The text was updated successfully, but these errors were encountered: