From aac2b36f193ecdd4d07b786159cbaceae2dee7eb Mon Sep 17 00:00:00 2001 From: Jasper Smet Date: Sun, 24 Aug 2025 20:57:50 +0200 Subject: [PATCH 1/2] Fix addBlocks and add option to append --- src/Controller/Component/HtmxComponent.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Controller/Component/HtmxComponent.php b/src/Controller/Component/HtmxComponent.php index b7eff5b..95019df 100644 --- a/src/Controller/Component/HtmxComponent.php +++ b/src/Controller/Component/HtmxComponent.php @@ -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 */ - 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; } From 1bb034ed82445a7d85d1cee1fc974a93156ea728 Mon Sep 17 00:00:00 2001 From: Jasper Smet Date: Sun, 24 Aug 2025 21:03:19 +0200 Subject: [PATCH 2/2] Document the append option --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 01125d0..ad52220 100644 --- a/README.md +++ b/README.md @@ -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