<?
CLASS SimpleTemplate{
	var $left_tag="{{";
	var $right_tag="}}";
	var $original_contents;
	var $contents;
	function SimpleTemplate($initParam){
		if(eregi("^(file=){1,1}",$initParam)){
	       $filename=eregi_replace("^(file=){1,1}","",$initParam);
		   $this->contents=implode("",file($filename));
		}else{
		   $this->contents=$initParam;
		}
		$this->original_contents = $this->contents;
	}

	function var2value($var,$val){
	    $this->contents=eregi_replace($this->left_tag.$var.$this->right_tag,$val,$this->contents);
	}

	function var2value_ary($array){
	    foreach($array as $var=>$val){
		   $this->var2value($var,$val);
		}
	}

    function reset(){
	    $this->contents = $this->original_contents;
	}
    
	function write(){
	    echo $this->contents;
	}

	function get_contents(){
	    return $this->contents;
	}
}
?>