Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

koa-xtpl

2.1.1 • Public • Published

koa-xtpl

NPM version NPM download Build Status Dependency Status devDependency Status Code Style

A node.js wrapper around xtemplate engine (easier for Koa 2)

Install

# npm 
$ npm install koa-xtpl --save
# or yarn 
$ yarn add koa-xtpl

Usage

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)

API

xtpl(options)

options

Type: object or string

Option or view root directory

root

Type: string

commands

Type: object

extname

Type: string

catchError

Type: boolean

encoding

Type: string
Default: utf-8

strict

Type: boolean

cache

Type: boolean

License

MIT © 汪磊

install

npm i koa-xtpl

Downloadsweekly downloads

4

version

2.1.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability