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

前端 未结 1 1774
萌比男神i
萌比男神i 2021-01-03 20:04

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.

1条回答
  •  伪装坚强ぢ
    2021-01-03 20:24

    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 讨论(0)
提交回复
热议问题