Posts Tagged ‘templating’

Read more

Data-Driven Templating in One Line

A quick snippet for this happy morning. Actually I’m going to format it so its a couple of lines…

var html = "<li><a href='{profileUrl}'><img src='{photoUrl}'/> {name}</a></li>".replace( /\{([^\}]+)\}/g, function(matches, name) {
  return store.getValue(item, name); 
});

Read the rest of this entry »