xtemplate / xtpl

nodejs wrapper around xtemplate engine (easier for expressjs and koajs)
MIT License
100 stars 25 forks source link

koa2 render出错时抛出异常 #17

Open heerake opened 6 years ago

heerake commented 6 years ago

目前会直接吃掉异常,返回undefined的content

chang-ke commented 6 years ago

能提供具体的错误和可复现代码吗?

heerake commented 6 years ago

@danmin25

let Koa = require('koa');
let xtpl = require('xtpl/lib/koa2');
let path = require('path');

let app = new Koa();

xtpl(app, {
    views: path.resolve(__dirname)
});

app.use(async (ctx) => {
    ctx.body = await ctx.render('./test', {
        number: 1
    });
});

app.listen(3333);

test.tpl内容为

{{number.noFunc(1)}}

错误在xtpl/lib/koa2, line55 没有处理error,是故意设计成这样的么

xtplRender(filePath, context, option)((e, data) => {
            content = data;
        });