feat: render function returns string (#89)

This commit is contained in:
Leo Kettmeir
2022-02-15 12:28:09 +01:00
committed by GitHub
parent d334b53320
commit 15f73e3274
3 changed files with 33 additions and 21 deletions
+5 -3
View File
@@ -26,7 +26,7 @@ export interface RenderOptions {
error?: unknown;
}
export type RenderFn = () => void;
export type RenderFn = () => string;
export class RenderContext {
#id: string;
@@ -178,10 +178,11 @@ export async function* render(
function render() {
try {
body = renderToString(vnode);
return body;
} catch (e) {
if (e && e.then) {
promise = e;
return;
return "";
}
throw e;
}
@@ -318,10 +319,11 @@ export async function suspenseRender(
function render() {
try {
body = renderToString(vnode);
return body;
} catch (e) {
if (e && e.then) {
promise = e;
return;
return "";
}
throw e;
}