You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some components should have a default display if no child is passed, but the problem is that when callinggetChildren(ctx).
But I get NopComponent. This is unacceptable because there is a nil check in the same function. I can't compare and understand whether there are child components or not.
Please add the HasChildren(ctx) function to the release, which will give an understanding.
This wouldn't replace the { children... } syntax, but { children...} is already redundant, since you can do @templ.GetChildren(ctx) to get the same result. It would be possible to update templ to replace { children...} with a @templ.GetChildren(ctx) statement if we wanted to slim down, but it's out of scope for this.
To implement this, we'd need some generator tests to ensure that if, if / else behaviour works OK, and that you get a NopComponent instead of nil if there are no children to prevent accidental panics where the ok value is ignored or used incorrectly. We'd also need some unit tests for the runtime function.
Happy to take a PR for this if someone else wants to implement, also happy to hear comments on the proposal, including naming the function something else.
Acceptable, it looks like due to the early calculation of child components it would be logical to use a flag whether the child components were initially passed or not, because the order of the call would then matter.
Some components should have a default display if no child is passed, but the problem is that when calling
getChildren(ctx)
.But I get
NopComponent
. This is unacceptable because there is a nil check in the same function. I can't compare and understand whether there are child components or not.Please add the
HasChildren(ctx)
function to the release, which will give an understanding.So, i want to do like this one:
The text was updated successfully, but these errors were encountered: