ehabd
ehabd

Reputation: 1077

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

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.

Upvotes: 24

Views: 15032

Answers (1)

McGarnagle
McGarnagle

Reputation: 102743

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

Upvotes: 34

Related Questions