@nioh/render
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

中间件: render

安装

Install with npm

npm i @server/render --registry=http://npm.zkh360.com

说明

基于 nunjucks 模板koa中间件

使用

import * as Koa from 'koa'
import { render } from '@server/render'

const app = new Koa()

app.use(render({
  debug: true,
  ext: 'html',
  path: path.resolve(__dirname, './views'),
  nunjucksConfig: {
    autoescape: true,
    noCache: true
  }
}))

app.use(async ctx => {
  if (ctx.request.path === '/') {
    await ctx.render('demo', {demo: 'hello world'})
  }
})

app.listen(3000)

ChangeLog

Tests

npm test

License

2019@ZKH-FE

Readme

Keywords

Package Sidebar

Install

npm i @nioh/render

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

3.21 kB

Total Files

4

Last publish

Collaborators

  • roei