DEV Community


Mustache with JavaScript in Browser

Joe Enos
Software developer/architect, mostly working with .NET and SQL Server.
・1 min read

Mustache is a fantastic simple templating engine that can be used in many different languages and frameworks.

One of those is ordinary JavaScript in the browser. If you have a simple application that doesn't need a big server or client side framework framework like ASP.NET or Angular, then you can still do some templating very easily.

There are several different ways of accomplishing this. Watch the video to see them in action.

  • You can keep your template in a JavaScript string, and render the HTML all in JavaScript.

  • You can keep your templates in separate standalone files and retrieve them with AJAX.

  • The templates can be stored in special template script tags in your page.

No matter which style you go with, the end result is the same.

Discussion (0)