Template.apex is a library to evaluate templates written in visualforce expression syntax.
Sometimes we have the need to provide support for customizable templates like email templates. In these situations, Template.apex can help you evaluate templates written in visualforce expression syntax, which is handy and easy to pick up for those experienced in Salesforce visualforce pages.
Template.apex has a dependency over R.apex and Script.apex.
Please include them before including Template.apex.
Template.apex uses Funcs from R.apex as the callback mechanism. If you want to go deeper with Template.apex, please do check out R.apex.
To evaluate a template written in visualforce expression syntax, what you need is only one line.
String output = new Template().evaluate('Hi {! UPPER(acc.Name) }', new Map<String, Object>{ 'acc' => new Account(...) });