.ig >>
<STYLE TYPE="text/css">
<!--
        A:link{text-decoration:none}
        A:visited{text-decoration:none}
        A:active{text-decoration:none}
        OL,UL,P,BODY,TD,TR,TH,FORM { font-family: arial,helvetica,sans-serif;; font-size:small; color: #333333; }

        H1 { font-size: x-large; font-family: arial,helvetica,sans-serif; }
        H2 { font-size: large; font-family: arial,helvetica,sans-serif; }
        H3 { font-size: medium; font-family: arial,helvetica,sans-serif; }
        H4 { font-size: small; font-family: arial,helvetica,sans-serif; }
-->
</STYLE>
<title>midriff: template syntax</title>
<body bgcolor=99cc99 vlink=0000FF>
<br>
<br>
<center>
<table cellpadding=2 bgcolor=FFFFFF width=550 ><tr>
<td align=right><a href="Contents.html">
<img src="img/midriff.gif" border=0><br><small>dynamic content system</a> &nbsp; &nbsp; </td></tr>
<td>
.>>

.TH template syntax TDH "06-MAR-2003   TDH scg@jax.org" 

.SH Template syntax
\fBMidriff\fR templates start with some underlying content (typically HTML) and add 
.ig >>
<a href="Contents.html">
.>>
\0directives
.ig >>
</a>
.>>
that do things.  
Some examples of directives are \fC#if\fR, \fC#while\fR, and
\fC#include\fR.
In \fBmidriff\fR, directives always begin with a pound sign (\fC#\fR), and must
be the first content on a line.  There can never be more than one directive per
line.  
.LP
Any line where the first non-whitespace content is \fC//\fR is a \fBcomment\fR
and is ignored.  Comments must be alone on the line.
.LP
\fBAny line that is not a directive or a comment is output directly\fR, with variables evaluated.
Hence there is usually no need for "print" statements, and a minimum of quoting hassles.

.ig >>
<br><br><br>
.>>

.SH Syntax summary
.LP
\fB#\fR = indicates a directive, such as \fC#if\fR or \fC#include\fR
.LP
\fB//\fR = a comment (must be 1st token on line)
.LP
\fB@\fR = used at the beginning of a variable name when its contents are to be displayed or referenced
.LP
\fB@@\fR = produces a literal at-sign
.LP
\fB$\fR = used at the beginning of 
.ig >>
<a href="func.html">
.>>
\0function
.ig >>
</a>
.>>
names

.ig >>
<br><br><br>
.>>

.SH Variables
\fBmidriff\fR templates can set and reference \fBvariables\fR.
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 
.ig >>
<a href="commalist.html">
.>>
\0lists,
.ig >>
</a>
.>>
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.
.LP
An at-sign (\fC@\fR) 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:
.nf
        \0Hello, my name is @NAME
        \0#set NAME = "Harvey Smith"
	\0#if @mode = 2
	\0Price: 3 @ $10/each
.fi

.LP
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.

.ig >>
<br><br><br>
.>>
.SH Special variables
The following special variables exist:
.LP
\fB@CGIPROG\fR . . . the full path name of the midriff cgi executable.  
.ig >>
<a href="links.html">
.>>
\0More info
.ig >>
</a>
.>>
.LP
\fB@HTMLURL\fR . . . the URL of a directory where static HTML, images, etc. reside
.ig >>
<a href="links.html">
.>>
\0More info
.ig >>
</a>
.>>
.LP
\fB@HTMLPATH\fR . . . the full path name of the HTMLURL directory
.ig >>
<a href="links.html">
.>>
\0More info
.ig >>
</a>
.>>
.LP
\fB@PROJDIR\fR . . . the full path name of your project directory
.ig >>
<a href="shell.html">
.>>
\0More info
.ig >>
</a>
.>>
.LP
\fB@MIDRIFF_VERSION\fR . . . the version of midriff that you are running

.ig >>
<br><br><br>
.>>

.SH 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 \fBmidriff\fR syntax is clearly different from HTML, XML, etc. can be taken
as a readability plus.
\fBmidriff\fR's template syntax does seem a bit clumsy compared
with languages that allow multiple statements per line or statements to span
lines.

.ig >>
<br>
<br>
</td></tr>
<td align=right>
<a href="Contents.html">
<img src="img/midriff.gif" border=0></a><br>
<small>dynamic content system &nbsp; &nbsp;<br>
<a href="Copyright.html">Copyright Steve Grubb</a> &nbsp; &nbsp;
</td></tr>
</table>
.>>
