文档没有提到 Mustache.to_html(),但是 Mustache.js 在线的每个教程都使用 Mustache.to_html()。因此,我肯定错过了一些珠宝。
代码示例将不胜感激。
查看源代码,似乎to_html基本上已被弃用:
// This is here for backwards compatibility with 0.4.x.
exports.to_html = function (template, view, partials, send) {
var result = render(template, view, partials);
if (typeof send === "function") {
send(result);
} else {
return result;
}
};
如您所见,它调用了render。一个区别是额外的(可选)发送参数,它是它调用的回调(将结果作为参数发送)。