Skip to content

Instantly share code, notes, and snippets.

@mizchi

mizchi/template.html

Last active Mar 27, 2021
Embed
What would you like to do?
<div>hello</div>
import * as path from "https://deno.land/std@0.91.0/path/mod.ts";
async function getTextFile(filepath: string) {
if (import.meta.url.startsWith("file://")) {
return await Deno.readTextFile(filepath);
} else {
const dir = path.dirname(import.meta.url);
const dest = path.join(dir, filepath);
const result = await fetch(dest).then((res) => res.text());
return result;
}
}
console.log(await getTextFile("./template.html"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment