-
Notifications
You must be signed in to change notification settings - Fork 87
/
index.d.ts
62 lines (55 loc) · 1.49 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* =================== USAGE ===================
import * as Koa from 'koa';
import * as views from 'koa-views';
const app = new Koa();
const render = views(__dirname + '/views', {
map: {
html: 'underscore'
}
});
app.context.render = render();
// app.use(render);
app.use(async function (ctx, next) {
await ctx.render('user', {
user: 'John'
});
});
=============================================== */
import { Middleware } from 'koa'
type viewsOptions = {
/*
* Whether to use ctx.body to receive the rendered template string. Defaults to true.
*/
autoRender?: boolean,
/*
* Default extension for your views
*/
extension?: string,
/*
* Map a file extension to an engine
*/
map?: any,
/*
* replace consolidate as default engine source
*/
engineSource?: any,
/*
* These options will get passed to the view engine. This is the time to add partials and helpers etc.
*/
options?: any,
}
/**
* return Function or Koa.middleware
* @param root Where your views are located. Must be an absolute path. All rendered views are relative to this path
* @param opts (optional)
*/
declare function views(root: string, opts?: viewsOptions): Middleware
declare namespace views {
const viewsOptions: viewsOptions;
}
export = views
declare module 'koa' {
interface ExtendableContext {
render(viewPath: string, locals?: any): Promise<void>
}
}