sei sicuro di voler reinventare la ruota?
http://smarty.php.net