The logic for a template is written as a set of functions written in the Ergo programming language. Ergo is a type-safe, non-Turing complete functional programming language, created by the Accord Project.
The Ergo functions for a template are called when transactions are received for processing, and return a response. Both the incoming requests and responses are modeled types.
You can create your own Smart Clause Templates and upload them to Clause.