Files
DefinitelyTyped/types/koa-hbs/index.d.ts
2017-03-24 14:27:52 -07:00

56 lines
1.3 KiB
TypeScript

// Type definitions for koa-hbs v1.x
// Project: https://github.com/gilt/koa-hbs
// Definitions by: Jacob Malone <https://github.com/jcbmln/>, Mudkip <https://github.com/mudkipme>
// Definitions: https://github.com/jcbmln/DefinitelyTyped
/* =================== USAGE ===================
import * as Koa from "koa";
....import hbs = require("koa-hbs");
var app = new Koa();
app.use(hbs.middleware({
viewPath: __dirname + '/views'
}));
app.use(async (ctx, next) => {
await ctx.render('main', {
title: 'koa-hbs'
});
});
=============================================== */
/// <reference types="koa" />
import * as Koa from "koa";
declare namespace Hbs {
export interface Middleware {
viewPath: Array<string> | string,
handlebars?: Function,
templateOptions?: {},
extname?: string,
partialsPath?: Array<string> | string,
defaultLayout?: string,
layoutsPath?: string,
contentHelperName?: string,
blockHelperName?: string,
disableCache?: boolean
}
}
declare class Hbs {
constructor();
middleware(opts: Hbs.Middleware): any;
}
declare const hbs: Hbs;
export = hbs;
declare module "koa" {
export interface Context {
render(tpl: string, locals?: {[key: string]: any}): Promise<void>;
}
}