Add support for view engines, PNPM
This commit is contained in:
23
src/views/ViewEngine.ts
Normal file
23
src/views/ViewEngine.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import {AppClass} from "../lifecycle/AppClass"
|
||||
import {Config} from "../service/Config"
|
||||
import {Container} from "@extollo/di"
|
||||
import {UniversalPath} from "@extollo/util"
|
||||
|
||||
export abstract class ViewEngine extends AppClass {
|
||||
protected readonly config: Config
|
||||
protected readonly debug: boolean
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
this.config = Container.getContainer().make(Config)
|
||||
this.debug = (this.config.get('server.mode', 'production') === 'development'
|
||||
|| this.config.get('server.debug', false))
|
||||
}
|
||||
|
||||
public get path(): UniversalPath {
|
||||
return this.app().appPath(...['resources', 'views']) // FIXME allow configuring
|
||||
}
|
||||
|
||||
public abstract renderString(templateString: string, locals: {[key: string]: any}): string | Promise<string>
|
||||
public abstract renderByName(templateName: string, locals: {[key: string]: any}): string | Promise<string>
|
||||
}
|
||||
Reference in New Issue
Block a user