gpt4 book ai didi

node.js - NodeJS 和 mustache : how to get partials working?

转载 作者:搜寻专家 更新时间:2023-11-01 00:18:59 26 4
gpt4 key购买 nike

我想在 Node 上使用 mustache,但由于某些原因,partials 不起作用:我创建了 2 个文件,app.jstest.mustache,两者都在同一个目录中。使用 package.json 文件和 npm 我已经为这个项目安装了最新版本的 mustache。文件如下所示:

应用程序.js:

var mus = require('mustache');
console.log(mus.render('test.mustache: {{>test}}'));

测试. mustache :

This is a test

如果我运行 node app.js 我希望得到以下输出:test.mustache: This is a test,但我只是得到: test.mustache:.

其他 mustache 标签确实按预期工作,甚至 mustache 的誓言测试也没有报告任何错误。

我应该怎么做才能让它正常工作?

最佳答案

使用 node-inspector 我已经用 Mustache 调试了上面的应用程序。事实证明,Mustache 不会自动包含部分文件,这与 manual 的相反。暗示(向下滚动到部分)。相反,您始终需要手动提供分音作为渲染方法的第三个参数。

关于node.js - NodeJS 和 mustache : how to get partials working?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11935840/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com