koa-swig-render
Koa view render based on Swig, support tags, filters, and extensions.
Last updated 6 years ago by jarvisjiang .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install koa-swig-render 
SYNC missed versions from official npm registry.

koa-swig-render

NPM version Build status Test coverage License Dependency status

Forked from koa-swig, but the usage is a little difference. That is render(app, {});app.use(render());

Koa view render based on Swig, support tags, filters, and extensions.

NPM

Usage

Install

npm install koa-swig-render

Features

  • First, automatically merge ctx.state from koa 0.14.
  • Second, automatically merge ctx.flash.
  • Finally, merge custom locals.

Example

var koa = require('koa');
var render = require('koa-swig');
var app = koa();

app.use(render({
  root: path.join(__dirname, 'views'),
  autoescape: true,
  cache: 'memory', // disable, set to false
  ext: 'html',
  locals: locals,
  filters: filters,
  tags: tags,
  extensions: extensions
}));

app.use(function *() {
  yield* this.render('index');
});

app.listen(2333);

Settings

  • swig options

    • autoescape
    • cache
    • locals
    • varControls
  • filters: swig custom filters

  • tags: swig custom tags

  • extensions: add extensions for custom tags

  • ext: default view extname

  • root: view root directory

  • writeBody: default(true) auto write body and response

Others

  • swig-extras A collection of handy tags, filters, and extensions for Swig.

Licences

MIT

Current Tags

  • 0.0.4                                ...           latest (6 years ago)

4 Versions

  • 0.0.4                                ...           6 years ago
  • 0.0.3                                ...           6 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (7)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |