Implementing the Mustache.js rendering method

First up, we have to grab the template, make a variable called template to do just this, and all we're going to do is select it with jQuery using the ID we just provided, #message-template. Now we need to call the html method, which is going to return the markup inside message-template, which is the template code, our paragraph tag in this case:

socket.on('newMessage', function (message) {  var template = jquery('#message-template').html();

Once we have that we can go ahead and actually call a method on Mustache, which was available to us because we added that script tag. Let's make a variable called html; this is the thing we're eventually going to add it to the browser and we're going to set ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.