If you’re used to interpolating server variables in HTML, templating will be familiar. There are a variety of templating libraries out there—your choice will probably depend on which DOM library you’re using. However, most of them share a similar syntax, which I’ll describe below.
Created by Microsoft, jQuery.tmpl is a templating plug-in based on John Resig’s original
work. It’s a well-maintained library and is fully documented on the
jQuery site. The
library has one main function,
jQuery.tmpl(), to which you can pass a template and some data. It renders a template element that you can append to the document. If the data is an array, the template is rendered once for every data item in the array; otherwise, ...