Page MenuHomeSealhub

test.ts
No OneTemporary

import { Readable } from "stream";
import { Templatable, tempstream } from ".";
import { Slot } from "./slot";
import streamToString from "./tostring";
const name = new Slot("noname");
const world = Promise.resolve(["Wo", "rld"]);
// a test
function html(
strings: TemplateStringsArray,
...params: Templatable[]
): Readable {
const title = new Slot("Default page title");
setTimeout(() => title.set("Changed page title"), 3000);
console.error(
"try playing around with the above timeout. Weird things happen when you go to e.g. 3000"
);
// process.exit(1);
return tempstream/* HTML */ `<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>${title}</title>
</head>
<body>
${tempstream(strings, ...params)}
</body> `;
}
const result = html`hello ${world}, and ${name}`;
streamToString(result).then(console.log);
// template`hello ${world}, and ${name}`.pipe(process.stdout);

File Metadata

Mime Type
text/html
Expires
Fri, Nov 28, 15:19 (1 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1066134
Default Alt Text
test.ts (907 B)

Event Timeline