-
Notifications
You must be signed in to change notification settings - Fork 22
Delphi Razor Syntax
The adaptation of Razor used in Delphi Relax has a rather simple syntax. First, it uses the @ symbol as marker, rather than tags or other notations. The symbol is followed by a special processing keyword or by a value, generally indicated with a dot notation as object.value, so you'll see tags like:
@object.value
The name of the object is a local name assigned with a registration process. The value is either the name of a property (for a generic object) or the name of a field if the object inherits from TDataSet. If there is no object with that name already associated with the processor, it will activate an OnGetValue event handler, for custom processing. Since the @ is used for special processing, in case you want an @ in the output (like in an email address) you should duplicate it, as in @@.
Note: The is a helper utility, DoubleAtSymbol, you can use to duplicate the @ symbol in a text, if present, so that it is retained in the output. Use it, for example, when returning an email address in a field.
The second notation is the use of braces, { and }, to denote conditional or repeated blocks. If used in a different context (that is, not after conditions), they won’t interfere and won't incur any special processing.
Furthermore, there are specific keyword-tags (which should be case insensitive): foreach, if, lang, layoutpage, loginrequired, loop, renderbody, and query. Their role in the following sections, after we look in some more details how to access basic values.