import ResponseFactory from './ResponseFactory.ts' import ViewEngine from '../../unit/ViewEngine.ts' import {Request} from '../Request.ts' /** * Response factory that renders a partial view as HTML. * @return ResponseFactory */ export default class PartialViewResponseFactory extends ResponseFactory { constructor( /** * The view name. * @type string */ public readonly view: string, /** * Optionally, the response context. */ public readonly context?: any, ) { super() } public async write(request: Request) { const views: ViewEngine = this.make(ViewEngine) request.response.body = await views.partial(this.view, this.context) return request } }