queckezz / koa-views

Template rendering middleware for koa (hbs, swig, pug, anything! :sparkles:)
MIT License
710 stars 87 forks source link

allow template absolute path #131

Closed lcxfs1991 closed 5 years ago

lcxfs1991 commented 5 years ago

@int64ago Please check

int64ago commented 5 years ago

I think you can achieve this purpose by setting proper path and relPath, so I'll close the PR, feel free to reopen it if necessary :-)

lcxfs1991 commented 5 years ago

Actually if we allow users to set absolute path, this is more understandable.

@int64ago

int64ago commented 5 years ago

The absolute path of template may lead to confusion if mixing with relative path in one project.

lcxfs1991 commented 5 years ago

If the user use absolute path, root path won't apply. I think that is a solution.

int64ago commented 5 years ago

This's what makes confusion.

How about the following example:

At the top of project:

app.use(views('/path/of/views', {
  // ...
}));

In one file:

ctx.render('path/of/template');

In another file:

ctx.render('/path/of/template');

It's strange and may cause bugs.