Creating and rendering template for newMessage

Creating a template and rendering it, is going to give you a pretty good idea about exactly what Mustache can do, then we'll go ahead and actually wire it up with our newMessage and newLocationMessage callbacks. To kick things off over inside index.html we are going to make a new template by defining a script tag just next the chat__footer div.

Now inside of the script tag, we're going to add our markup, but before we can do that we have to provide a couple of attributes on script. First up this is going to be a reusable template and we're going to need a way to access it, so we'll give it an id, I'm going to call this one message-template, and the other property we're going to define is something ...

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.