Directives

Basically, the input syntax is standard HTML with some slight extensions. The most obvious extension are the directives. Every directive is on a line by itself, and the line starts with a "#". You can have whitespace around the "#" if you want.

There are a number of directives:

  • ## Comment Any line starting with two # characters is considered a comment. This is not elegant.
  • #include FILENAME This directive processes the named file as if it were included at this point. Included files can also use any of the directives including the include directive. Note that it is possible to cause loops. It is not productive. The FILENAME can be surrounded by double quotes or angle brackets to keep things similar to C. You can also load in a portion of a file as described with the #split directive.
  • #localcode FILENAME This directive is much like the include directive, except that it reads the named file into the webc compiler. This allows for user written functions which can be called by the call directive.
  • #define NAME VALUE This directive allows you to associate any value with a name. Where ever the name shows up in the original file will be replaced with the value in the generated HTML file. The replacement value can not contain newline characters. Unlike more conventional languages, the NAME can include most any character. It is also not suggested that you have a VALUE contain some other name, as you will get inconsistant results. The webc compiler defines a number of NAMEs already. All of these names are of the form __name__. Thus it is suggested that you avoid using names with two leading and trailing underscores for your own variables, as they conflict with future webc names. However, you should choose names not likely to show up in HTML text. A single leading and trailing underscore would be a good convention.
  • #call FUNCTION It is possible to call any function in the webc compiler. There are no parameters. There are a number of standard functions, and you can define your own and incorporate them using the localcode directive.
  • #pragma NAME This is a collection of hacks to get around certain issues. The only names currently defined are nodefine which disables turns expansion back on.
  • #callable FUNCTION This lets webc know that FUNCTION can be called anyplace it sees FUNCTION(...). The FUNCTION is a piece of code defined in Perl code and is passed a string with all of the text between the parenthesis and the first closing parenthesis. The return value of the function is substituted in place. This doesn't deal with balanced parenthesis, nor is it wise to make part of the argument of one function the return value of another function.
  • #split NAME This separates the file into different logical sections. Using #include "filename" NAME will read in only the selected split of the file. This was added by John Lombardo to allow the head and tail sections to be maintained in a single file.
Some of these directives refer to files (e.g. the include and localcode). If you specify a relative filename, it is assumed to be in the same directory as the file which is using that name. This has ramifications if an include file includes another include file.
[Previous] [Introduction] [Overview] [Directives] [Variables] [Functions] [Invocation] [Suggestions] [Examples] [Perl API] [Next]
Source for this file can be found in directives.wc.



[scripts] [Send a comment]
PEAK



Last modified 30 Mar 1998
Dave Regan
http://www.peak.org/~regan/

Comments to: PEAK Support Team