Introduction
ASPRunnerPro uses the built-in template language. ASPRunnerPro templates cleanly separate your presentation layer (HTML, CSS, etc.) from the application code. The main idea is to simplify visual templates by moving all logic and JavaScript to ASP files.
Template language reference
• all template tags are enclosed within delimiters { and }. All content outside delimiters is displayed as static HTML.
• template variables start with the dollar $ sign. They may contain numbers, letters, and underscores.
Example
{$variable_name}
The string {BEGIN block_name} ... {END block_name} is used to define the block section (loops, condition statements).
Functions
assign name, val
is used to assign the value val to the variable name.
Working with the templates
Here is a basic example of how templates work. Add the following code to the Before display event:
xt.assign "name", "george smith"
xt.assign "address", "45th & Harris"
The template file contains the output with template tags that ASPRunnerPro replaces with assigned content.
Example 1. Changing 'Nothing to see' message
By default ASPRunnerPro displays 'Nothing to see. Run some search.' message when search returns no data. If you need to change this message to something custom, you can add the following code to BeforeDisplay event of the List page:
xt.assign "message", "my message"
Template file
<html>
<head>
<title>User Info</title>
</head>
<body>
User Information:<p>
Name: {$name}<br>
Address: {$address}<br>
</body>
</html>
Output
<html>
<head>
<title>User Info</title>
</head>
<body>
User Information:<p>
Name: george smith<br>
Address: 45th & Harris<br>
</body>
</html>
Changing a button label dynamically
Here is how you can change a custom button label dynamically.
1. Insert a Custom Button into one of the pages using Page Designer. Use the following as button label:
{$button_label}
2. Use the following code in the BeforeDisplay event of the page in question:
xt.assign "button_label", "Edit Customer"
{BEGIN} ... {END} blocks
The template file contains a set of code sections wrapped by {BEGIN ...} and {END ...}.
Template file
{BEGIN Model_fieldblock}
<tr><td class=shade width=150>Model</td><td width=250>
{$Model_value}
</td></tr>
{END Model_fieldblock}
Use the following code in the Before display event:
xt.assign("Model_fieldblock",true)
When you use true, the HTML code between {BEGIN ...} and {END ...} appears in the output.
xt.assign("Model_fieldblock",true)
When you use false, the HTML code between {BEGIN ...} and {END ...} is hidden.
See also:
•Template files processing rules (Files.txt)
•Page Designer: Working with page elements