Mustache

We use Mustache.js as our templating engine. It allows us to easily combine JSON data arrays with HTML templates and render the results to the screen. By using MustacheJS the syntax for our templates can also be produced server-side by one of their other libraries.

Other areas of interest for MustacheJS and Blockstrap include:


Example Code

As seen from the corresponding documentation, a quick example of how Mustache can be used:

var view = {
    title: "Joe",
    calc: function () 
    {
        return 2 + 4;
    }
};
var output = Mustache.render("{{title}} spends {{calc}}", view);

This would render as follows:

Joe spends 6

- back to top


URL Routing

By default, if visiting the root URL of the application without any additional URL paramters or hashes, the data and HTML for the view will be fetched via AJAX from the following locations (further defined within the necessary configuration files):

If visiting the accounts URL such with the hash as follows your-application.com#accounts, Blockstrap will assume you want to load the accounts`page and will also load:

It will first render the index page before then merging the accounts data and rendering the content from accounts by replacing the configured $.fn.blockstrap.settings.content_id element with the additional HTML.

- back to top


  1. Related Articles
  2. Back to Assets
  3. Dependencies
  4. Boostrap
  5. Mustache
  6. LESS.css
  7. Table of Contents