I'm calling a web service that returns an array of objects in JSON.
I want to take those objects and populate a div with html. Let's say each object contains a url and a name.
If i wanted to generate the following html for each object:
<div><img src="the url" />the name</div>
Is there a best practice for this? I can see three ways of doing it:
- Concatentate strings
- Create elements
Use some sort of templating plugin like http://beebole.com/pure/ which seems like a cool yet immature technology
UPDATE, a friend suggested the following: generate the html on the server, then serve up via json, this is faster and allows you to reuse the template on any server side stuff you are doing