xiongwilee / Gracejs

A Nodejs BFF framework, build with koa2(基于koa2的标准前后端分离框架)
https://grace.wilee.me
MIT License
1.39k stars 238 forks source link

nunjucks 要添加个过滤器怎么加呢? #40

Closed haizhilin2013 closed 7 years ago

haizhilin2013 commented 7 years ago

nunjucks 要添加个过滤器怎么加呢?

项目中需要用到不少过滤器,比如时间,货币等。。。看到nunjucks本身是支持的,要怎么结合进来呢?

var nunjucks = require('nunjucks');
var env = new nunjucks.Environment();

env.addFilter('shorten', function(str, count) {
    return str.slice(0, count || 5);
});
xiongwilee commented 7 years ago

开了个分支完美支持nunjuck,https://github.com/xiongwilee/koa-grace/tree/nunjucks