Skip to content
/ koa-xtpl Public

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

License

Notifications You must be signed in to change notification settings

zce/koa-xtpl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 © 汪磊

About

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

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published