A node.js wrapper around xtemplate engine (easier for Koa 2)
# npm
$ npm install koa-xtpl --save
# or yarn
$ yarn add koa-xtpl
demo.xtpl
<p>{{ title }}</p>
demo.js
const path = require('path')
const Koa = require('koa')
const xtpl = require('koa-xtpl')
const app = new Koa()
// root
app.use(xtpl(path.join(__dirname, 'views')))
// or options
app.use(xtpl({
root: path.join(__dirname, 'views'),
extname: 'xtpl',
commands: {}
}))
app.use(async ctx => {
await ctx.render('demo', { title: new Date() })
})
app.listen(3000)
Type: object
or string
Option or view root directory
Type: string
Type: object
Type: string
Type: boolean
Type: string
Default: utf-8
Type: boolean
Type: boolean