HTP

htp on-line reference : IF, ELSEIF, ELSE, /IF

Table of Contents
  Introduction
  License
  Tutorial
  Usage
  HTP Tags
    ALTTEXT
    BLOCK
    BLOCKDEF
    DEF
    FILE
  > IF
    INC
    IMG
    IMAGEURL
    OPT
    OUTPUT
    QUOTE
    SET
    UNDEF
    UNSET
    USE, $
    WHILE
    <!---
  History
  Wish list
  Bugs

syntax

<[ref]if disabled_because_xyz>
  ...
<[ref]/if>

synopsis

IF, NOT, ELSEIF, ELSE, and /IF are the building blocks for conditional processing. The basic form is shown above.

"Conditional" is either a "compare" or "is defined" operation. A compare operator is a test of the value of a macro against a literal string:

  <[ref]DEF NAME="HEADERIMG" OPTION="SRC TITLE SIZE">
    <[ref]IF size>
        <FONT SIZE=${size}>
    <[ref]/IF>
    <[ref]IMG SRC=pics/${src}>
    <[ref]USE title>
    <[ref]IF size>
        </FONT>
    <[ref]/IF>
  <[ref]/DEF>

  <HEADERIMG SRC="logo.gif" SIZE="+2" TITLE="A title">

  <HEADERIMG SRC="logo.gif" TITLE="Normal sized title">

  This will fail:
  <HEADERIMG SRC="logo.gif" ALT="Our logo" TITLE="Another title">

  Instead, use * like this:
  <[ref]DEF NAME="MYIMG" OPTION="SRC *">
    <[ref]IMG SRC="pics/${src}" $*>
  <[ref]/DEF>
   
  <MYIMG SRC="logo.gif" ALT="Our logo">

and a defined operator is a test of a macro's existance:

  <[ref]imageurl url="http://my.domain.org/" path="/var/www/my.domain/">
  <[ref]imageurl url="other.domain.org/" path="/var/www/other.domain/">

  For this line: <[ref]img src="logo.gif">
  the local filename "logo.gif" will be used to determine image dimensions
  (no URL replacement).

  For this line: <[ref]img src="http://my.domain.org/logo.gif">
  the local filename "/var/www/my.domain/logo.gif" will be used.

  But for this line: <[ref]img src="http://other.domain.org/logo.gif">
  the local file cannot be found (no prefix match), so the image dimensions
  will not be added.

  Order is important; last IMAGEURL tag takes precedence:
  <[ref]imageurl url="/" path="/var/www/htdocs/">
  <[ref]imageurl url="/test/" path="/var/www/test/">

  <[ref]img src="/image.gif"> and <[ref]img src="/test/image.gif"> are mapped to
  /var/www/htdocs/image.gif and /var/www/test/image.gif, resp.
  If the order of the imageurl lines would be swapped, the second
  image would be mapped to /var/www/htdocs/test/image.gif.

If the NOT tag is present in the IF markup, the evaluation of the conditional is reversed. The first IF or ELSEIF condition that evaluates to true is chosen. If none of the conditions is true the ELSE block is taken if it is present. A conditional block must be closed with the /IF tag. IF tags can be nested.

  page source
  htp project
  htp homepage
hosted by
Sourceforge
HTML coding Powered by htp
htp on-line reference / http://htp.sourceforge.net/ref/
Authors: Jim Nelson, Jochen Hoenicke, Michael Möller.
Maintainers: Jochen Hoenicke.

Copyright © 1995–96 Jim Nelson.
Copyright © 2001–2014 Jochen Hoenicke.
Permission to reproduce and distribute this hypertext document granted according to terms described in the License section.

last updated Sat May 16, 2015