-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
<named slot> is not a function #148
Comments
Just check if slot exists using @if($slots.head)
<head>
{{{ await $slots.head() }}}
</head>
@end |
Ok, I can. But it's a huge step back. I know I don't have to explain to you how it worked in Adonis v5, but it requires more code to achieve the same result. |
This is a strong statement for one additional line of code. It totally makes sense to verify that a slot exists before trying to use it. In fact, before, you were generating bad HTML because you had an empty |
That's just an example with the smallest amount of HTML anyone needs in this issue.
One line of code for every slot. You don't know what's the scope of the projects people are working on. But. I know I can make a global function or |
Using components for layouts is a very common practice. Just search for the same in the Vue ecosystem or in the React ecosystem. Yes, they work different from layouts in first place and you just have to find the right pattern with them. But anyways, we won't be adding |
I work with them on the daily basis for 5 years, I don't have to search for it. I just wanted to not use the if statement for checking whether the slot exists. That was the issue. You removed it from previous version of Edge. |
Package version
6.0.1
Describe the bug
I want to make a layout which can be extended by other .edge files.
When we had
@layout
and@section
everything was easy. We could set a default value for the section and even extend it with@super
. Now, when having to use@component
, things are bit different, but to the point.Consider a really simple layout with two slots - named
head
and defaultmain
:When using it in another file this way:
or with the old syntax:
We get the
$slots.head is not a function
error.I must specifically define an empty named slot content for it to work:
I want to be able to add the slot content optionally. It would also be awesome to be able to have default slot content.
Reproduction repo
No response
The text was updated successfully, but these errors were encountered: