Skip to content

Commit

Permalink
Merge pull request #215 from hemmesdev/main
Browse files Browse the repository at this point in the history
Added support for Htmlable contents in BaseElement
  • Loading branch information
freekmurze authored Apr 19, 2024
2 parents e611cac + 1287115 commit f3cac70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/BaseElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ protected function parseChildren($children, $mapper = null): Collection
{
if ($children instanceof HtmlElement) {
$children = [$children];
} elseif ($children instanceof Htmlable) {
$children = $children->toHtml();
}

$children = Collection::make($children);
Expand Down
7 changes: 7 additions & 0 deletions tests/Html/ButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
);
});

it('can create a button with Htmlable contents', function () {
assertHtmlStringEqualsHtmlString(
'<button>Hi</button>',
$this->html->button(new \Illuminate\View\ComponentSlot('Hi'))
);
});

it('can create a button with a type', function () {
assertHtmlStringEqualsHtmlString(
'<button type="submit">Hi</button>',
Expand Down

0 comments on commit f3cac70

Please sign in to comment.