1 Star 2 Fork 0

张维烨/maong-platform

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
templating.js 692 Bytes
一键复制 编辑 原始数据 按行查看 历史
张维烨 提交于 2021-06-12 08:51 . 项目迁移
'use strict';
let nunjucks = require('nunjucks');
function createEnv(path, opts) {
path = path || 'views';
opts = opts || {};
let envOptions = {
autoescape: opts.autoescape || true,
throwOnUndefined: opts.throwOnUndefined || false,
trimBlocks: opts.trimBlocks || false,
lstripBlocks: opts.lstripBlocks || false,
watch: opts.watch || true,
noCache: opts.noCache || true
}
let env = nunjucks.configure('views', envOptions);
return env;
}
module.exports = async (ctx, next) => {
let env = createEnv();
ctx.render = function (views, model) {
ctx.body = env.render(views, model);
}
await next();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/lv_y/maong-platform.git
[email protected]:lv_y/maong-platform.git
lv_y
maong-platform
maong-platform
master

搜索帮助