In the CMS context a template is a blueprint to create pages or smaller components. Whenever you add a page with Pages app you must specify its template to create the page.
A template consist of:
A template script defines the output, typically HTML, and is interpreted by a Renderer. The script is written in a templating language such as FreeMarker or JSP.
Dialogs are used for content entry. A dialog defines the edible content properties of a template. Pages, area and component templates can all use dialogs.
The model is a JavaBean implementing RenderingModel. Use it to implement complex logic. The model can execute any Java code to retrieve data from the repository or from an external source. The results are available to the template script for rendering on the page.
Elements of the Magnolia template mechanism: