queckezz/koa-views

Add file path to ctx

jgdev opened this issue · 3 comments

jgdev commented

I have a logger middleware, I would like to know what file was rendered in the end of the response.

@jgdev Hi, any code snippet? Actually, koa-views ONLY add a render method in ctx, I don't think it has any relation to your logger middleware.

jgdev commented

@int64ago

koa-views/src/index.js

Lines 42 to 50 in db8a41e

return render(resolve(path, paths.rel), state).then(html => {
// since pug has deprecated `pretty` option
// we'll use the `pretty` package in the meanwhile
if (locals.pretty) {
debug('using `pretty` package to beautify HTML')
html = pretty(html)
}
ctx.body = html
})

I just want to create an instance of the value resolve(path, paths.rel) in somewhere, maybe ctx.renderPath.

You can use getPaths manually.