lib/src/views/ViewEngineFactory.ts

24 lines
763 B
TypeScript
Raw Normal View History

import {Instantiable, FactoryProducer} from '../di'
2021-06-03 03:36:25 +00:00
import {ViewEngine} from './ViewEngine'
import {PugViewEngine} from './PugViewEngine'
import {ConfiguredSingletonFactory} from '../di/factory/ConfiguredSingletonFactory'
2021-03-09 00:07:55 +00:00
2021-03-25 13:50:13 +00:00
/**
* Dependency factory whose token matches the abstract ViewEngine class, but produces
* a particular ViewEngine implementation based on the configuration.
*/
@FactoryProducer()
export class ViewEngineFactory extends ConfiguredSingletonFactory<ViewEngine> {
protected getConfigKey(): string {
return 'server.view_engine.driver'
2021-03-09 00:07:55 +00:00
}
protected getDefaultImplementation(): Instantiable<ViewEngine> {
return PugViewEngine
2021-03-09 00:07:55 +00:00
}
protected getAbstractImplementation(): any {
return ViewEngine
2021-03-09 00:07:55 +00:00
}
}