Skip to content

Instantly share code, notes, and snippets.

@voidnerd
Created August 7, 2022 23:58
Show Gist options
  • Save voidnerd/6e964e716a2b5b2aa22438912da2b3f3 to your computer and use it in GitHub Desktop.
Save voidnerd/6e964e716a2b5b2aa22438912da2b3f3 to your computer and use it in GitHub Desktop.
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