evaluate

evaluate(object) -> String

Applies the template to the given object’s data, producing a formatted string with symbols replaced by corresponding object’s properties.

Examples


var hrefTemplate = new Template('/dir/showAll?lang=#{language}&categ=#{category}&lv=#{levels}');
var selection = {category: 'books' , language: 'en-US'};

hrefTemplate.evaluate(selection);
// -> '/dir/showAll?lang=en-US&categ=books&lv='

hrefTemplate.evaluate({language: 'jp', levels: 3, created: '10/12/2005'});
// -> '/dir/showAll?lang=jp&categ=&lv=3'

hrefTemplate.evaluate({});
// -> '/dir/showAll?lang=&categ=&lv='

hrefTemplate.evaluate(null);
// -> error !