To use the Modstache library, include Modstache.js or Modstache.min.js file:

   <script src="Modstache.min.js"></script>

This will create the Modstache object that exposes the following API :

  • fill - assigns data properties. Works on an HTML string or DOM fragment. Returns the filled DOM fragment.
  • fillHTML - assigns data properties to an HTML string by replacing mustache syntax {{}}
  • fillDOM - assigns data properties to a DOM fragment by looking for elements with the {} attribute
  • options - gets/sets the default options for Modstache.

The Modstache library can also be accessed through the _M_ variable.


    var targetFragment = Modstache.fill(target:HTML string or DOM fragment, data:object, optional options:object);


    var html = Modstache.fillHTML(target:HTML string, data:object, optional options:object);


    var fragment = Modstache.fillDOM(target:DOM fragment, data:object, optional options:object);


    var options = Modstache.options({ modified properties });