简体   繁体   English

从nunjucks要求node.js库

[英]Requiring node.js libraries from nunjucks

Is there a way to require a node.js library from inside a nunjucks template? 有没有办法从nunjucks模板内部要求node.js库?

Something similar to the following: 类似于以下内容:

{% set strftime = require('strftime') %}
var env = nunjucks.configure([...
...
env.addGlobal('require', function(lib) { 
    return require(lib);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM