koa-xtpl
A node.js wrapper around xtemplate engine (easier for Koa)
Last updated 3 years ago by zce .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install koa-xtpl 
SYNC missed versions from official npm registry.

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

Current Tags

  • 2.1.1                                ...           latest (3 years ago)
  • 2.0.0                                ...           next (4 years ago)

9 Versions

  • 2.1.1                                ...           3 years ago
  • 2.1.0                                ...           3 years ago
  • 2.0.0                                ...           4 years ago
  • 2.0.0-alpha.5                                ...           4 years ago
  • 2.0.0-alpha.4                                ...           4 years ago
  • 2.0.0-alpha.3                                ...           4 years ago
  • 2.0.0-alpha.2                                ...           4 years ago
  • 2.0.0-alpha.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (2)
Downloads
Today 0
This Week 21
This Month 53
Last Day 0
Last Week 10
Last Month 19
Dependencies (1)
Dev Dependencies (1)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |