Also, the best way to do it can depend on the system using the tpl file. In smarty templates, you can do a certain amount of logic within the template itself. In something like phpBB it is usually just tags that are filled in without logic within the template.
So, if you told me what you are trying to do with what kind of system it might help
