How do you set jade basedir option in an express app? (the “basedir” option is required to use “extends” with “absolute” paths)

孤街浪徒 提交于 2019-12-04 22:59:17
robertklep

You can use this:

app.locals.basedir = '/your/base/directory';

Or, using the newer Express method,

app.locals.basedir = path.join(__dirname, 'views');

In express, you'll notice that there is,

app.set('views', path.join(__dirname, 'views'));

You can just put this line in then,

app.locals.basedir = app.get('views');

Which makes the basedir available to jade.js so it can resolve absolute paths.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!