setup.php: Refactor for Template class

Issue #145.