|
Template language is the framework that powers visual and code
templates in ASPRunnerPro. Most template language expressions are
references to the project file. Template language elements are
wrapped by ## characters:
1. Strings
Example:
|
·
|
"this is a \"string\"" - this is a
"string";
|
|
·
|
"\"\\\" is a backslash" - "\" is a
backslash.
|
2. Numbers
Examples:
3. Variables
Variables start with @ character.
Examples:
|
·
|
@BUILDER - root element of project
file.
|
|
·
|
@TABLE - pseudo-variable that points to
the current selected table.
|
|
·
|
@a, @field - regular variables.
|
|
·
|
@TABLE.arrFieldObj - array of fields that
belong to the current table.
|
|
·
|
@field.EditFormatObj.m_strDefaultValue -
default field value.
|
Variables belong to one of the following data types: strings,
numbers, objects and arrays.
4. Boolean expressions
0,"" - false, anything else - true.
1. Comparison operators
|
·
|
= or <> - does not equal.
|
|
·
|
<= - less than or equal to.
|
|
·
|
>= - greater than or equal to.
|
You can only compare numbers and strings. Comparison result is
either 0 or 1.
2. Boolean
Result is either 0 or 1.
3. Parenthesis
Example:
|
(@field.m_bAddPage or @field.m_strLabel=="ID") and not @Table.m_strCaption==""
|
4. Dot operator
To access structure members, the operator used is the dot
operator denoted by (.).
Example:
|
@field.m_ListFormatObj.m_nColWidth
|
5. The Array length property is
'len'
Example:
6. Priority order
There is an established order with the priority of each
operator. From greatest to lowest priority, the priority order is
as follows:
1. Display a value of a
variable or an expression
Examples:
|
·
|
##@field.m_bAddPage## - displays 0 or
1.
|
|
·
|
##@field.m_strLabel## - displays 'Year of
Make'.
|
2. Conditional statement
if <Boolean expression>,
elseif <Boolean expression>, else, endif
Examples:
|
##if @field.m_bAddPage##
...
##elseif @field.m_strLabel=="ID"##
...
##else##
...
##endif##
|
3. Loop statements
Foreach
<array> as <variable> , endfor
The variable is created when loop starts and destroyed with the
'endfor'.
Example:
|
##foreach @TABLE.m_arrFieldObj as @field##
if strField="##@field.m_strName##" then
Label
= "##@field.m_strLabel##"
##endfor##
|
Repeat
<number> [variable], endrepeat
Repeat loop body N times. Variable, if specified, ranges from 1
to <number>.
Filter
Allows nodes filtering.
Example. Get a list of fields that require validation:
|
##foreach @TABLE.m_arrFieldObj as @field filter @field.m_strValidateAs order @field. m_nEditPageOrder##
##if @first##
include("include/validate.asp");
##endif##
##endfor##
|
Nested loops
Repeat and Foreach loops can be nested.
Example:
|
##foreach @BUILDER.Tables as @t##
##foreach @t.arrMasterTables[strMasterTable==@TABLE.strDataSourceTable].arrMasterKeys
as
@dk##
$masterquery.="&masterkey##@index##=".rawurlencode($data["##@dk s##"]);
##endfor##
$showDetailKeys["##@t.strShortTableName##"]=$masterquery;
##endfor##
|
Loop variable @index
The loop variable @index will take on the values 1, 2, ..., N
through each of the N iterations of the loop's body.
Pseudo-variables @first and
@last
@first takes a value of:
|
·
|
1 - during the first loop pass;
|
It is useful when you need to perform some action only once i.e.
skip a comma in front of table name:
|
$tables
= Array("Table1","Table2","Table3");
##if !@first## ,
##endif##
|
In loops, @first terminates execution of the nearest enclosing
foreach or repeat statement. Control then passes to the statement
that follows the terminated statement, if any:
|
##foreach @TABLE.m_arrFieldObj as @field##
##if @field.m_EditFormatObj. m_strValidateAs && @first##
include("include/validate.asp");
##endif##
##endfor##
|
Order - sort order other
than default.
Example. Get a list of fields ordered by nEditPageOrder (field
order on the edit page):
|
##foreach @TABLE.m_arrFieldObj as @field order @field. nEditPageOrder##
##if @field.m_EditFormatObj. m_strValidateAs &&
@first ##
include("include/validate.asp");
##endif##
##endfor##
|
Modifiers are required to encode quotes, slashes and other "bad"
characters that can break template language elements. You can
combine several modifiers. Modifiers order is important.
Example:
List of modifiers abbreviations:
|
·
|
hs - shapehtml will be applied first,
shapescript will be applied after that.
|
|
·
|
s - replaces " with "".
|
|
·
|
q - strings wrapped by single
quotes.
|
|
·
|
h - HTML-encodes string.
|
|
·
|
j - replaces ' with \'.
|
|
·
|
n - replaces spaces with  .
|
|
·
|
u - URL-encodes string.
|
|
·
|
w - adds wrappers around the field name
([field name] or `field name`).
|
|
·
|
t - adds wrappers around the table name
([dbo].[table name] or `table name`).
|
|
·
|
g - replaces all non alphanumeric
characters with underscores.
|
|
·
|
p - builds parameter name for UPDATE,
INSERT, DELETE (.NET specific).
|
|
·
|
8 - converts UTF8 string to national
language charset.
|
|
·
|
o - removes owner/schema from table
name.
|
|
·
|
d - converts name to CamelCase. Example:
"Order details" becomes OrderDetails.
|
|
·
|
l - replaces line feeds and carriage
returns with spaces.
|
|
·
|
a - builds valid ASP variable name from
table name. Used in Data Access Layer.
|
|
·
|
f - builds valid ASP variable name from
field name. Used in Data Access Layer.
|
|
·
|
x - builds valid property name (.NET Data
Access Layer specific).
|
|
·
|
y - builds valid class name (.NET Data
Access Layer specific).
|
Macros and constants are processed and replaced with the actual
code. Macros and constants are defined in the macros.txt file.
Constant definition example:
|
##define <name> <value>##
##define FORMAT_DATABASE_IMAGE "Database
image"##
##define EDIT_DATE_SIMPLE 0##
|
Macro definition example:
|
##define UseRTE(@field)
(@field.strEditFormat==EDIT_FORMAT_TEXT_AREA
&& @field.m_EditFormatObj.m_bUseRTE)
##
|
Macros and constants are processed in the same way. Therefore,
we suggest to follow this naming convention: constant names are
written in upper case (e.g. FORMAT_DATABASE_IMAGE), macro names use
CamelCase convention (e.g. UseCalendar). Spaces are not allowed in
macro or constant names.
Example:
|
##if @field.strViewFormat==FORMAT_DATABASE_IMAGE##
##if UseRTE(@field)##
##foreach Fields as @f##
##Master.strCaption##
|
Additional
language elements
1. Specific array
element
To access specific array element use <array>[<condition>].
Example:
|
##@TABLE.arrFieldObj[strName==@TABLE.strKeyField].strLabel##
|
This example shows how to access the Label property of a key
column field or any other field.
|