Last active
March 27, 2021 10:20
-
-
Save mizchi/03cb0dc1bb344c8a0fb8e7e48de4aaaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div>hello</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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