import pug from 'pug'; import Koa from 'koa'; export declare class KoaPug { viewPath: string; noCache: boolean; helpers: { [key: string]: (...args: any[]) => any; }; private defaultOptions; private defaultLocals; constructor(options?: PugOptions); get locals(): { [key: string]: any; }; set locals(value: { [key: string]: any; }); get options(): PugOptions | undefined; set options(options: PugOptions | undefined); /** * Compile .pug file * @param tpl The path of template file * @param locals Variables and helpers that passed to Pug compiler * @param compileOptions */ private compileFile; /** * Compile a Pug template string * @param tpl Template string or the path of template file */ private compileString; /** * Render Pug tamplate * @param tpl Template string or the path of template file * @param locals Variables and helpers that passed to Pug compiler * @param options */ render(tpl: string, locals?: any, options?: RenderOptions): Promise; /** * Bind render function to Koa context * @param app Koa instance */ use(app: Koa): void; } export default KoaPug; export { PugOptions, RenderOptions }; declare module 'koa' { interface BaseContext { render: (tpl: string, locals?: any, options?: RenderOptions, noCache?: boolean) => Promise; } } interface PugOptions extends pug.Options { [key: string]: any; /** * Koa instance */ app?: Koa; /** * Paths of helpers. */ helperPath?: any[]; /** * Add a list of variables to make accessible in templates */ locals?: { [key: string]: any; }; /** * The root directory of all Pug templates */ viewPath?: string; } interface RenderOptions extends PugOptions { /** * Render template string instead template file */ fromString?: boolean; }