/*
 * template.js
 *
 */
var Template = {
  /**
  Evaluates the string with the object provided
  @params string, object
  @public
  */
  evaluate: function(template, values) {
  	template = template || '';
  	values = values || {};

    var replace_value = function (str, match) {
      try { var value = eval('values.'+match.split(":")[0]); } catch(e) { return str; }

      if ((arr = match.split(":")) && arr.length > 1) {
        return eval(arr[1]+'("'+value.toString().inspect().replace(/"/g, '\\"')+'")');
      } else {
        return value;
      }
  	};

  	return template.replace(/#\{([^{}]*)\}/g, replace_value);
  }
}
