What is the difference between Mustache.render() and Mustache.to_html()?

你说的曾经没有我的故事 提交于 2019-12-03 20:36:01

问题


The documentation makes no mention of Mustache.to_html(), but every tutorial for Mustache.js online uses Mustache.to_html(). Therefore I am surely missing some jewels.

Code examples would be very much appreciated.


回答1:


Looking at the source, it seems to_html has essentially been deprecated:

// 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;
    }
};

As you can see it invokes render. The one difference is the extra (optional) send parameter, which is a callback it invokes (sending the result as a parameter).



来源:https://stackoverflow.com/questions/10872615/what-is-the-difference-between-mustache-render-and-mustache-to-html

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