Package: thinkmap.template

The thinkmap template module is responsible for loading and rendering Thinkmap JavaScript templates, which end in the extenstion of .jst

Thinkmap JavaScript templates behave like most template engines. They themselves look like any typical HTML file but JavaScript rendering logic is supported via the <% %> operators while outputting content is supported via <%= %> operators.

Examples:

Let's say a template file exists on the server and it is called list.jst. This list.jst file is used to create a list of items from an array inside a div in our HTML page. The contents of the JST file will then have the following
    <% for (var i = 0; i < users.length; i++) { %>
  • <%= users[i].lastname %>
  • <% } &>
Now assumming the list.jst file is relative to the html file and stored under a directory called templates, then it can be rendered to the div like so: thinkmap.template('templates/list.jst') .renderTo(document.getElementById('myDiv'),{users:usersArray}); The usersArray already exists in our HTML page but as we pass it in as data under 'users', it can be referred to in the template file under users which can be see in the for loop.

Functions