koa-swig
Koa view render based on Swig, support tags, filters, and extensions.
Usage
-
v2.x
appcontextrender = ; -
v1.x
;
Install
npm install koa-swig
Features
- First, automatically merge
ctx.state
from koa 0.14. - Second, automatically merge
ctx.flash
. - Finally, merge custom locals.
Example
var koa = ;var render = ;var app = ; appcontextrender = ; app; app;
// koa v2.xvar co = ; appcontextrender = co; app;
Settings
-
- autoescape
- cache
- locals
- varControls
- tagControls
- cmtControls
-
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
Methods
-
render.swig.setLocals
-
render.swig.getLocals
Others
- swig-extras A collection of handy tags, filters, and extensions for Swig.
Licences
MIT