midriff: template syntax

dynamic content system
| Manual page for template(syntax)

## Template syntax

Midriff templates start with some underlying content (typically HTML) and add directives that do things. Some examples of directives are `#if`, `#while`, and `#include`.`` In midriff, directives always begin with a pound sign (`#`), and must be the first content on a line. There can never be more than one directive per line.

Any line where the first non-whitespace content is `//` is a comment and is ignored. Comments must be alone on the line.``

Any line that is not a directive or a comment is output directly, with variables evaluated.`` Hence there is usually no need for "print" statements, and a minimum of quoting hassles.``

## Syntax summary

# = indicates a directive, such as `#if` or `#include`

// = a comment (must be 1st token on line)

@ = used at the beginning of a variable name when its contents are to be displayed or referenced

@@ = produces a literal at-sign

$ = used at the beginning of function names

## Variables

midriff templates can set and reference variables.`` Variable names must begin with a letter and may contain letters, digits, underscore (_) and period (.).`` Names are case-sensitive. Maximum length of a variable name is 38 characters.`` Variables may hold numbers, alphanumerics, or lists, but are always stored in alphanumeric form, with a maximum content length is 250 characters.`` All variables are global in scope across page templates within a process.``

An at-sign (`@`) is used at the beginning of a variable name when its contents are to be displayed or referenced.`` Otherwise, the at-sign should not be used.`` Examples:

             Hello, my name is @NAME
             #set NAME = "Harvey Smith"
    	 #if @mode = 2
    	 Price: 3 @ $10/each

An attempt to display or reference the contents of a variable that has never been assigned a value will result in cancellation of the evaluation (the variable name will be displayed transparently) and no error condition will be raised.``

## Special variables

The following special variables exist:

@CGIPROG . . . the full path name of the midriff cgi executable. More info

@HTMLURL . . . the URL of a directory where static HTML, images, etc. reside More info

@HTMLPATH . . . the full path name of the HTMLURL directory More info

@PROJDIR . . . the full path name of your project directory More info

@MIDRIFF_VERSION . . . the version of midriff that you are running

## Syntax pros and cons

Since with systems like this most statements are usually output statements, the fact that print statements aren't usually needed is convenient.`` Also, the fact that midriff syntax is clearly different from HTML, XML, etc. can be taken as a readability plus.`` midriff's template syntax does seem a bit clumsy compared with languages that allow multiple statements per line or statements to span lines.``
dynamic content system
Copyright Steve Grubb

Markup created by unroff 1.0, `` `` March 06, 2003.