从 NPM(节点模块)解析 nunjucks 模板?

Resolving nunjucks templates from NPM ( node modules )?

正在寻找一种方法来获取 nunjucks 导入/包含以从 NPM node_modules 文件夹中解析。

例如,假设我们安装了这样一个包:

npm i -S @example/cards

我们现在想在模板中像这样从中导入:

{% import "@example/templates/birthday.html" as birthday %}

想法?

正如@Aikon Mogwai 指出的那样,这将起到作用:

nunjucks.configure('node_modules');

我在 @superflycss/cli 中实现了它,以防有人需要参考实现。