eSite An introduction to eSite

eSite is a parser for documents written using the PHP syntax. It is designed so that the content of the document can be seperated from the layout in manners that all dynamic content management systems support, but that I have not found in an opensource site editing tool that is designed to support static content.

eSite works by pushing a document through a two-step parsing process. The first step runs some simple transformations on the document to be parsed that are designed to preserve PHP markup in the document1, and to glue the document to a template, if required. The second step parses the document as if it were a PHP document, capturing the output and saving it to disk.

A simple example

Below are a minimal document and template, demonstrating how the parser works:

$title = "Hello World";
[ESITE BEGIN]
<h1>Hello World!</h1>
[ESITE END]

And the code for a minimal template:

<html>
<head>
<title><?esite echo($title); ?></title>
</head>
<body>
<?esite esite_parse_document_content($esite_document_content); ?>
</body>
</html>

As you can see, the template would be a PHP file, except for the replacement of <?php with <?esite. Since eSite is written in PHP, eSite documents and templates use the PHP syntax with all PHP builtin functions plus any functions you may have added to PHP using the PEAR system.

The [ESITE BEGIN] and [ESITE END] blocks in the document are simply conviences that are transformed into standardized chunks of PHP code during the first phase of the parsing process.


1 This step is concerned with the preservation of PHP markup if only because the parser is written in PHP, and for no other reason than that if the parser did not do this, PHP documents would not be usable after handled by this tool.