The basic idea is that you have html templates and that you use javascript to "fill in the blanks".
Here's a short primer: http://www.gethifi.com/blog/javascript-templates-and-how-we-...
There are various libraries you can use to make this easier for yourself. Underscore and handlebars are too good options.