/*
Script: Template.class.js
	string template processor
*/

/*
Class: Template
	Template-Klasse. Schön. Schnieke. Einfach
	
	weitere Infos @WIKI : Mootools_klasse_template

Author:
	Michael Rotmanov (rotmanov@sipgate.de)
*/
var Template = new Class ({
	initialize: function(template, pattern) {
		this.template = template.toString();
		// Workaround for the wonderful Opera strictness
		this.template = this.template.replace(/{/ig, '_');
		this.template = this.template.replace(/}/ig, '_');
		this.pattern = $H(pattern);
	},
	evaluate: function(pattern) {
		var newString=this.template;
		if (pattern) { this.pattern = $H(pattern); }
		this.pattern.each( function(value, key) {
			newString=newString.replace(eval("/#_"+key+"\_/ig"), value);
		});
		return newString;
	}
 });
