HTP

htp on-line reference : DEF, /DEF

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]imageurl url="imageurl" [ path="path/in/local/filesystem" ]>

synopsis

DEF creates metatags, which is a fancy way of saying it creates new tags. The mechanism is very similar to BLOCK macros, except that the USE tag is not used to expand them. Instead, they are expanded by their own name. For example:

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

Some metatags will require an opening and closing tag (comparable to and ). In this case, you should use the BLOCKDEF macro. Another slightly faster alternative is to use two metatags, the opening tag and the closing tag with a preceding slash. For example:

    <[ref]unset email_addr>

You should really use BLOCKDEF, though, as it will check for matching end tag. It is not that slower.

Options can be passed to a metatag, which can then expand as if it were a SET macro. Option names are parameterized with the OPTION attribute. Multiple options can be listed by separating their name with a space (which therefore requires they be surrounded by quotes.)

htp will do very specific checking of parameters when a metatag is invoked. htp assumes that all parameter options to the metatag are optional. This is why the HEADERIMG definition uses IF to verify the SIZE option is defined before expanding it in the block. If a parameter is required, simply expand it without first checking. When htp expands the metatag and the macro is not defined, it will halt processing and complain with an error message and the required macro name. Normally htp will not allow parameters not listed in the OPTION attribute to be added to the tag. This is why the third invocation of HEADERIMG will fail. There is no ALT parameter specified in the OPTION attribute. However, there is the special option *, which matches every other parameter. It should be used to pass all other options to another tag.

Metatags can be removed by using the UNDEF tag. Note that both open and close tags must be removed with UNDEF. Removing one will not remove both.

Warning: Although possible, def should not be used to override standard HTML and htp tag names, as this can cause much confusion and unexpected results. The def tag can even be used to override its own tag name. Because of the problems this can cause, its highly recommended to not override known tag names.

You can find some other examples in the [ref]metatag section of the tutorial.

  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