Now the next step in the process is going to be to get all the data showing, we have a from property and a createdAt property too. We actually have access to that createdAt property via formattedTime.
We're going to go ahead and uncomment the formattedTime line, and this is the only one we're actually going to carry over to the new system. I'm going to add it up inside newMessage callback:
socket.on('newMessage', function (message) {
var formattedTime = moment(message.createAt).format('h:mm a');
var template = jQuery('#message-template').html();
var html = Mustache.render(template, {
});
Because we do still want to use formattedTime when we render. Now before we do anything else with the template, let's go ahead and simply pass in the values. We already passed the text value in. Next up, we can pass in from, it's accessible via message.from, and we can also pass in a timestamp. You can call that property whatever you like, I'm going to continue to call it createdAt and set it equal to the formattedTime:
var html = Mustache.render(template, {
text: message.text,
from: message.from,
createdAt: formattedTime
});