Gruppo su Facebook Gruppo su LinkedIn

Genphp

Genphp is a tool that permits to separate structure and content of a collection of documents (tipically website pages), creating common templates and content files that are then merged into the final documents.

The great advantage of Genphp it's that all your documents are created and updated with one command. It's also possible to insert inside template e content files PHP code that must be executed once just after the merge. Finally common phrases can be collected in a glossary file (key-value pairs) and automatically inserted in the final documents in place of the relative keys.

Download

The latest version of Genphp is 0.4, which corrects some minor bugs.

Documentation

Example:

Template file (genphp/templates/template.html):

<html>
<head>
<meta name="author" content="<!-- GLOSS author -->" />
<title><!-- BLOCK title --></title>
</head>
<body>
<-- BLOCK body -->
</body>
</html>

Content file (genphp/content/index.content):

<!-- BEGIN title -->
Example page
<!-- END title -->
<!-- BEGIN body -->
This is an example page for <a href="<!-- GLOSS genphp -->">Genphp</a>.
<!-- END body -->

Glossary file (genphp/glossary):

author Nicola Soranzo
genphp http://www.golug.it/genphp.html

Now execute from a shell the genphp script:

# cd genphp
# ./genphp

Output file (genphp/www/index.html):

<html>
<head>
<meta name="author" content="Nicola Soranzo" />
<title>Example page</title>
</head>
<body>
This is an example page for <a href="http://golug.it/genphp.html">Genphp</a>.
</body>
</html>

Every <!-- BLOCK blockname --> element in the template file is replaced by the content of the block included between <!-- BEGIN blockname --> and <!-- END blockname --> in the content file.
Every <!-- GLOSS key --> element in the template an in the content files is replaced by the value corresponding to key in the glossary file.

Content, template and output directories are configurable, and so are the glossary file and content and default output file extensions. Moreover, in every content file you can specify a different template and output file extension.

Conctat

For any question or suggestion, you can contact the author Nicola Soranzo.