<$if COND=
expression>
code to be processed if condition matches<$elseif COND=
expression>
(optional) code to be processed if alternative condition matches<$else>
(optional) code to be processed if none of previous conditions matched</$if>
Both <$if>
and <$elseif>
require a boolean attribute
COND
; false
is represented by an empty string,
true
by any non-empty string. Normally, you will like to
set COND
using
expressions.
<$if COND=(NAME="sepp")> You must be sepp! </$if>
This one inserts the text "You must be sepp!
", if the attribute
NAME
has the value "sepp
". Note that the
"=
"-operator performs a case-insensitive string-comparison,
so setting NAME="SEPP"
would lead to the same result.
<$if COND=(NAME="sepp")> You must be sepp! <$else> I don't know you. </$if>
Setting NAME="sepp"
will create the same text as above. Any
other value for NAME
will insert
"I don't know you.
".
Nesting them is also possible, of course:
<$if COND=(NAME="sepp")> You must be sepp! <$if COND=(HOME="austria")> Hollareiduliö! An Austrian! <$else> <(HOME)> is a strange country. </$if> <$else> A strange guy from a strange place. </$if>
You can not compare hsc's <$if>
to primitive and clumsy
#if
of the C-preprocessor. The main difference is that
you can use <$if>
inside macros and that expressions are
recalculated for every new call of the macro.
<$macro TRY-A HREF:uri/r TITLE:string/r> <$if COND=(Exists(HREF))> <A HREF=(HREF)><(TITLE)></A> <* insert link to HREF *> <$else> <(TITLE)> <* insert plain title *> </$if> </$macro>
This one inserts a link to an URI specified with HREF
, using
TITLE
as link text; but only, if the destination (local) URI
can be accesed. If the required document is not available, only the plain
text without a link will be inserted.
The "/r
" behind the declaration of the macro-attributes
is short for "/required
" and means that the macro needs both
of these attributes to be set during the macro-call.
For example, you can utilize this macro using
You should read the document about recent <TRY-A HREF="../bugfixes.html" TITLE="bufixes"> if there are any.
This leads to the text
You should read the document about recent bugfixes if there are any.
with a anchor around the term "bugfixes
" if the document
"../bugfixes.html" exists.