Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ $this->Htmx->addBlock('userTable');
The `addBlocks()` function allows you to add multiple blocks to the list of blocks that should be rendered
```php
$this->Htmx->addBlocks(['userTable', 'pagination']);
$this->Htmx->addBlocks(['userTable', 'pagination'], true); // Appends the blocks to the existing array.
```

### OOB Swap
Expand Down
11 changes: 8 additions & 3 deletions src/Controller/Component/HtmxComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,16 @@ public function addBlock(string $block): static
/**
* Add blocks to render
*
* @param array $block List of block names to render
* @param array $blocks List of block names to render
* @param bool $append Whether to append the blocks or replace existing ones
Comment thread
josbeir marked this conversation as resolved.
*/
public function addBlocks(array $block): static
public function addBlocks(array $blocks, bool $append = false): static
{
$this->blocks[] = $block;
if ($append) {
$this->blocks = array_merge($this->blocks, $blocks);
} else {
$this->blocks = $blocks;
}

return $this;
}
Expand Down