code: function format(str, ctx) {
  	var splitter = '{',
  		isInside = false,
  		segment,
  		valueAndFormat,
  		path,
  		i,
  		len,
  		ret = [],
  		val,
  		index;
  	
  	while ((index = str.indexOf(splitter)) !== -1) {
  		
  		segment = str.slice(0, index);
  		if (isInside) { // we're on the closing bracket looking back
  			
  			valueAndFormat = segment.split(':');
  			path = valueAndFormat.shift().split('.'); // get first and leave format
  			len = path.length;
  			val = ctx;
  
  			// Assign deeper paths
  			for (i = 0; i < len; i++) {
  				val = val[path[i]];
  			}
  
  			// Format the replacement
  			if (valueAndFormat.length) {
  				val = formatSingle(valueAndFormat.join(':'), val);
  			}
  
  			// Push the result and advance the cursor
  			ret.push(val);
  			
  		} else {
  			ret.push(segment);
  			
  		}
  		str = str.slice(index + 1); // the rest
  		isInside = !isInside; // toggle
  		splitter = isInside ? '}' : '{'; // now look for next matching bracket
  	}
  	ret.push(str);
  	return ret.join('');
  }
docs: Format a string according to a subset of the rules of Python's String.format method.