Skip to content
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

Merged
merged 7 commits into from
Sep 30, 2024

Conversation

Quarkz14
Copy link
Contributor

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

Copy link
Collaborator

@joerdav joerdav left a 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
Copy link
Collaborator

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.

Suggested change
// 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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}
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@Quarkz14 Quarkz14 requested a review from joerdav September 28, 2024 20:15
@a-h a-h merged commit 3c65b43 into a-h:main Sep 30, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants