Class MAIN. Processing request

Parser processes requested document in the following way:

1.
It reads, compiles, and initializes:
a) Configuration file;
b) all files named auto.p, which are searched for in root directory and down-through directories tree until the directory where requested document belongs;
c) requested document itself.
Taken all together, they are what is defined as class
MAIN.
Initialization is done by calling method
auto in each of the loaded files. If method's definition contains a parameter, the loaded file's name will be passed.
Note: result of method's work will not be output to a visitor.

2.
Then, method
main of class MAIN is called without parameters.
This means that each of the mentioned files can define method
main. The one which was defined last will be called. This method's definition will override all other possible definitions.
The result of this method's work will be output to the visitor unless method
postprocess is defined.
If file has not a single method defined, its whole content will be regarded as definition of method
main.
Note: specifying
$response:body[of non-standard response] redefines text received by a visitor.

3.
If class
MAIN has method postprocess defined, result of method main's work is passed to it as the only parameter and it is the result of postprocess that a visitor will get.
Thus, you get an opportunity of "extra polishing" the result of your code's work.

Simple example
If we add this definition into file auto.p located in your root directory…

@postprocess[body]
^if($body is string){
    ^body.match[Jack][g]{Jill}
}{
    $body
}


…it will result in replacing
Jack with Jill in every page.
Do not forget to check the type, there can be some file.



Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 05.08.2005