add template.class.php.
add a demo to test,fix a lot of bugs.