最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is the difference between Mustache.render() and Mustache.to_html()? - Stack Overflow

programmeradmin0浏览0评论

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.

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.

Share Improve this question asked Jun 3, 2012 at 17:53 ehabdehabd 1,0773 gold badges9 silver badges15 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 34

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).

发布评论

评论列表(0)

  1. 暂无评论