-
-
Notifications
You must be signed in to change notification settings - Fork 279
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
feat: templ.Join method renders multiple components into a single component #929
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution and time!! A few small nits here and there I spotted.
join.go
Outdated
"io" | ||
) | ||
|
||
// Pass any number of templ.Components to get a single templ.Component with the components rendered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go function comments should begin with the name of the documented function.
// Pass any number of templ.Components to get a single templ.Component with the components rendered | |
// Join returns a single `templ.Component` that will render provided components in order. | |
// If any of the components return an error the Join component will immediately return with the error. |
@@ -235,6 +235,49 @@ func main() { | |||
<p>Dynamic contents</p> | |||
</div> | |||
``` | |||
## Joining Components | |||
With your templ components you can use `templ.Join` to generate a single `templ.Component` from your components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With your templ components you can use `templ.Join` to generate a single `templ.Component` from your components. | |
Components can be aggregated into a single Component using `templ.Join`. |
join_test.go
Outdated
} | ||
return nil | ||
}) | ||
components := []templ.Component{hello, world} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These definitions would probably be cleaner defined in the table test directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initialise them in the test structs now.
Heyoo,
I have a PR for the proposal suggested in this issue I followed the example solution you given @a-h. I have updated the docs too to explain the new Join method with an example in the
Temple Composition
section. Let me know what you think. I will rename the commit message as part of any changes in the feedback