Files
DefinitelyTyped/types/hbs/hbs-tests.ts
DavidM77 067defebd0 Add types for hbs npm package (#23091)
* Add types for hbs

* Use dtsg-gen generated tsconfig.json

* Add additional tests

* Now lints with less cheating

* Avoid losing type information
2018-01-23 16:19:23 -08:00

30 lines
795 B
TypeScript

import * as express from 'express';
const app = express();
app.set('view engine', 'html');
import hbs = require('hbs');
// The idiom for this is
// app.engine('html', require('hbs').__express);
// However this undermines the test since the return type of require() is any
app.engine('html', hbs.__express);
hbs.registerHelper('helper_name', (testParm: number) => testParm++);
hbs.registerPartial('partial_name', 'partial value');
hbs.registerPartials(__dirname + '/views/partials');
hbs.registerPartials(__dirname + '/views/partials', () => {});
hbs.localsAsTemplateData(app);
const safeString = new hbs.handlebars.SafeString("string");
const instance1 = hbs.create();
const instance2 = hbs.create();
app.engine('html', instance1.__express);
app.engine('hbs', instance2.__express);