Skip to content

Commit

Permalink
Add more details
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed Aug 24, 2022
1 parent 1f3f99c commit 2f6f903
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export interface AstroGlobal extends AstroGlobalPartial {
*/
has(slotName: string): boolean;
/**
* Asychronously renders this slot and returns HTML
* Asynchronously renders this slot and returns a string
*
* Example usage:
* ```astro
Expand All @@ -216,6 +216,21 @@ export interface AstroGlobal extends AstroGlobalPartial {
* <Fragment set:html={html} />
* ```
*
* A second parameters can be used to pass arguments to a slotted callback
*
* Example usage:
* ```astro
* ---
* html = await Astro.slots.render('default', ["Hello", "World"])
* ---
* ```
* Each item in the array will be passed as an argument that you can use like so:
* ```astro
* <Component>
* {(hello, world) => <div>{hello}, {world}!</div>}
* </Component>
* ```
*
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
*/
render(slotName: string, args?: any[]): Promise<string>;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/render/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Slots {
warn(
this.#loggingOpts,
'Astro.slots.render',
`Expected second parameter to be an array, received a ${typeof args}`
`Expected second parameter to be an array, received a ${typeof args}. If you're trying to pass an array as a single argument and getting unexpected results, make sure you're passing your array as a item of an array. Ex: Astro.slots.render('default', [["Hello", "World"]])`
);
} else {
if (expression) {
Expand Down

0 comments on commit 2f6f903

Please sign in to comment.