Skip to content

Commit 4b7c470

Browse files
authored
Merge pull request #247 from hpacleb/feat-add-script-if-method
feat: Add addScriptIf method
2 parents e5d03dd + a46716e commit 4b7c470

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Html/Builder.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,15 @@ public function addScript(string $view): static
265265
return $this;
266266
}
267267

268+
public function addScriptIf(bool $condition, string $view): static
269+
{
270+
if ($condition) {
271+
$this->addScript($view);
272+
}
273+
274+
return $this;
275+
}
276+
268277
public function addScriptIfCannot(string $ability, string $view): static
269278
{
270279
if (! (Gate::allows($ability))) {

0 commit comments

Comments
 (0)