Chapter 6. Templates

Table of Contents

1. Dynamic content
2. Optional or required content
3. Content type aware templating
4. Conditional templating
5. Nested conditions
6. Ignoring parts
7. Fragments
8. Summary

Projector offers a very simple templating mechanism. Templating is used to insert dynamic content into static web pages or any other kind of document. You may have come across different types of templating, as a java programmer you might at least know JSP. In a JSP you mix the layout of a page with programming instructions that generate the dynamic parts of the page.

This is very nice, if you have some simple web pages that need to show some data from a database or any other backend system. This is a nice thing from the programmer’s point of view, but it is no good if you for example want to relaunch your website with a brand new design. The designer can by accident delete or modify some code and this can cause some real trouble.

Projector’s templating is very easy and it does not allow you to write any Java source code into the template. You just can insert special tags where dynamic content should be filled in.