THE META-HTML LANGUAGE REFERENCE MANUAL

Introduction [TOC] Language Features

Overview of Meta-HTML

Sections contained within:


The Purpose of Meta-HTML

HTML is a description layout language. It describes in general the placement and visual style of elements in a page. These elements are generally sequences of text, with an occasional image thrown in for good measure.

Meta-HTML is an interpreted computer language with dynamic variables and flow-control statements. Although it is not a complete general purpose computer language in the traditional sense (i.e., you cannot write a version of a Meta-HTML interpreter in Meta-HTML) it does perform processing and decision making of and on data elements.

A quick example for the impatient is in order. The text:

You are connected to ``metahtml.sourceforge.net'' and reading text written by Brian J. Fox.

is produced in Meta-HTML by:

  <b>You are connected to ``<get-var ENV::SERVER_NAME>'' and
     reading text written by <get-var the-author>.</b>

As the WWW grows, more and more document providers are realizing that stateless connections are only useful for retrieving documents full of static information, and that, at times, it can be very useful to remember state pertaining to the browser that is connecting.

The problem of keeping state for a particular browser user has been resolved by various individuals; all of the solutions require information to be passed back and forth between the browser and the server. For example, to play a WWW Blackjack game could involve the passing back and forth of information including the current wins/losses of the user, which cards have been dealt from the deck so far, and so forth. This information is most often passed to and fro in the form of a "magic" URL. The problems with passing information in this way are two-fold:

  1. The information can be modified by the user before sending it back, which might allow a user to put more money in his or her bank account, for example, and, less importantly,

  2. The URL looks "ugly", since there is a large amount of information present which doesn't describe the essence of the location that the user is connecting to.

Another mechanism can be taken advantage of when both the server and browser being used support HTTP Cookies. While this solves the problem of "ugly" URLs, (this mechanism does not place information in the URL) it generates a new problem: the user must be in possession of a compliant browser, and be communicating with a compliant server. In addition, the information can be changed by the user before sending it back.

Meta-HTML solves the problem of keeping state for a particular session, and it does it in a server and browser independent manner. Our method requires no additional CGI programs to be written. You can read about the technical details in the Session Operators section of this manual.


Implementation

Initially, the vast majority of World Wide Web (WWW) documents consisted of static pages of text and images, which were described using HTML, and displayed using a browser which understood only the HTML language. The nature of a WWW connection is stateless by definition; each request for information is not associated in any way with any previous request for information, even when from the same source.

Connections are made from a browser to a WWW server, in which the browser requests a particular item of data by specifying a Universal Resource Locator (URL). The server looks up the URL, and then returns the data contained within. While most URLs are static HTML documents, there exists a mechanism in which a program can be run. The output of such a program is an HTML document, and such programs are referred to as Common Gateway Interface, or CGI programs.

Meta-HTML is currently implemented as a CGI program which can be executed every time the server is ready to retrieve a document. As before, the document to be retrieved can be a file of HTML, an image, or a CGI program to be executed. However, the document can also be a file of Meta-HTML code, in which case the benefits of dynamic variables and flow-control statements are fully realized.

Although this implementation method is not server-specific, you still must make a couple of configuration changes to your HTTP server in order to hide the Meta-HTML program from the user. Details are in the Installation Guide.


Syntax Overview

A Meta-HTML document consists of plain text, HTML directives, and Meta-HTML statements.

The syntax of the Meta-HTML language was designed to be as similar to HTML as possible, so as to not sacrifice readability of the total document. All of the Meta-HTML statements are delivered as a form of HTML tags. There are two types of Meta-HTML tags: simple and complex.

A simple tag begins with an open angle bracket (<) and ends with a corresponding close angle bracket (>). The text enclosed within the brackets is called the body; it can contain assigned variables and positional arguments.

A complex tag begins with what looks exactly like a simple tag, continues throughout the body of the text, and ends with the a matching closing tag. This is analogous to the use of tags within HTML. The body of a complex tag is all of the text which appears between the opening tag and the closing tag, exclusive of those tags themselves.

Here is an example of using the simple tag set-var:

    <set-var foo=bar>
  

Here is an example of using the complex tag when:

    <when <get-var foo>>
      The value of `foo' is <get-var foo>.
    </when>
  

Note that both the set-var and when forms have opening tags which contain additional material. This material is used to supply information to the form.

Additionally note that ``simple'' and ``complex'' do not refer to the complexity of the function performed; they simply refer to the syntax used to write the form in a document. For example, the simple tag var-case performs a complex operation based upon the arguments it is given.

Variables assigned in the opening (or simple) tag have the form:

    name=value
  

This gives the variable referred to as name a local value of value. Variable assignments such as these give the Meta-HTML writer a way to pass dynamic arguments to a function. For example, the with-open-database form can open the requested database in one of 3 modes; you control which one by locally assigning the variable mode within the form:

    <with-open-database db "/phones.db" mode=<get-var db-mode>>
     ...
    </with-open-database>
  

Quoting Syntax

At times, you will need to quote the expressions that you pass to various Meta-HTML functions. You do this with double quotes (") and blackslashes (\). Here is a somewhat hairy example of quoting:

    <if <get-var "Space Name">
        <get-var "Space Name[space index]">
      <set-var space-name-present=false>>
  

For most cases, quoting is unnecessary, because open braces are expected to match close braces, and doubles quotes are expected to come in pairs. This is the usual case. For example:

    <ifeq <get-var foo[index]> <get-var bar>
        <set-var array[index]=<get-var bar>-found>
      <set-var array[index]=<get-var bar>-missing>>
  

In the above example, no quoting was required because the only whitespace which appeared in the expression was within a set of matched braces.


The META-HTML Reference Manual V2.0 Copyright © 1995, 1998, Brian J. Fox
Found a bug? Send mail to bug-manual@metahtml.org