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

ehabd picture ehabd · Jun 3, 2012 · Viewed 13.9k times · Source

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.

Answer

McGarnagle picture McGarnagle · Jun 3, 2012

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