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
Copy file name to clipboardExpand all lines: README.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -875,6 +875,19 @@ This is just a file with access to global vars: ${testVar}`,
875
875
exportdefaulttemplateIterator
876
876
```
877
877
878
+
### Choosing a template return type
879
+
880
+
Use the simplest return type that fits your needs:
881
+
882
+
| Return type | Multiple outputs | Custom filename | Use when |
883
+
|---|---|---|---|
884
+
| String | No | No (derived from template filename) | Single file, filename from template name |
885
+
| Object | No | Yes | Single file with a custom output path |
886
+
| Array | Yes | Yes | Fixed set of output files known at build time |
887
+
| AsyncIterator | Yes | Yes | Any async work, or a dynamic number of outputs |
888
+
889
+
Start with a string return and only switch to a more complex type when you need what it provides. An async generator is the right choice when you need to do async work (such as calling `renderInnerPage` on multiple pages) and produce more than one output file.
890
+
878
891
### RSS Feed Template Example
879
892
880
893
Templates receive the standard variables available to pages, so its possible to perform page introspection and generate RSS feeds of website content.
0 commit comments