Created
August 7, 2022 23:58
-
-
Save voidnerd/6e964e716a2b5b2aa22438912da2b3f3 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
import { Edge } from 'edge.js' | |
import path from 'path' | |
import { LooseObject } from '../types' | |
export default class ViewService { | |
public constructor( | |
public view: string, | |
private data: LooseObject | null = null | |
) {} | |
public get path(): string { | |
return path.join(__dirname, '../views') | |
} | |
public async getHtml(): Promise<string> { | |
const edge = new Edge({ cache: false }) | |
edge.mount(this.path) | |
const html = await edge.render(this.view, this.data) | |
return html | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment