Chapter 2. Template syntax

Table of Contents

2.1. Introduction
2.2. Comments
2.3. Blocks and variables
2.4. Expressions
2.5. Functions
2.5.1. apply()
2.5.2. array()
2.5.3. capitalize()
2.5.4. count()
2.5.5. countWords()
2.5.6. cycle()
2.5.7. date()
2.5.8. length()
2.5.9. lower()
2.5.10. parseInt()
2.5.11. trim()
2.5.12. upper()
2.5.13. wordwrap()
2.6. Tags
2.7. Instructions
2.7.1. Section
2.7.2. Tree
2.7.3. Pagesystem
2.7.4. Conditions
2.7.5. Separator
2.7.6. Var
2.7.7. Include
2.7.8. Place
2.7.9. Default
2.7.10. Capture
2.7.11. For
2.7.12. Foreach
2.7.13. Php
2.7.14. Literal
2.7.15. Dynamic
2.7.16. Bind
2.7.17. Insert
2.7.18. BindEvent
2.7.19. BindGroup
2.8. Components
2.8.1. Defined components
2.8.2. An undefined component
2.8.3. Component tag reference
2.8.4. Component reference
2.9. XML-Syntax Mode
2.10. Master templates

In this chapter we will describe the template syntax used in the templates. The syntax is inspired by XML. If you are familiar with this language, you will find here some similar elements, like opening and enclosing tags, parameters etc. However, OPT is intended to work with all the text content and includes the features that XML does not have. There is a mode called XML Syntax Mode. It makes the tags look like in XML language, but remember - it is only an emulation, which accepts even invalid code.

Firstly, the manual provides basic information about tags and comments. Next, the blocks and expressions are explained. Finally, we describe all the functions, instructions and components, and end with the XML Syntax Mode.

This chapter is intended to the template designers. We know that some of them may not know any of the programming languages, and no doubt, the OPT syntax has the power of such language. If you are such person, remember that you do not have to use all of the programming features (probably you will use only the simplest parts). We tried to make the descriptions as simple as possible, however we had also to describe the whole syntax (it is a reference manual, not a tutorial). We marked the text with colored bars that tell more about the programming experience required from the reader.

Note: Although OPT allows programming on the template side (there is all the required stuff: expressions, conditional instructions and loops), this is not its main philosophy! Unlike some other template engines, the programming should be used only if there is no other way to implement something you want. OPT has all the tools required to have clean and easy to read templates.