We can restrict the allowed values that can be bound to the variable by specifying the content type. In our example we expect that the username is plain text, so we can add this to our template:
<html>
<body>
<h1>Hello <%username;optional;text/plain%></h1>
</body>
</html>If someone using our template tries to bind a number value to the username variable, Projector will tell him not to do so. You can enumerate more than one legal content type by separating them with a comma.
If you want restrict the valid content types, you always have to specify, if the variable is optional or required.
As you see, it is really simple to write a Projector template if you are familiar with languages like HTML or XML. You can use this templating mechanism to generate documents of any other markup based language.
The restriction of the content type is very useful in many ways: You can show the user of the template what kind of content is expected at a special position as this is often not fully described by the variables names. You can even restrict the content type in a way that will show that for example an HTML table is expected as content of a variable. By this way it is possible for Projector to ensure that the generated pages contain valid HTML and don’t get broken by inserting some malformed content.