Index < Previous     Next >
Step 1: Your first file [ ^ ]
Suppose you have a file 'p.html' that you wish to generate it throught wpp.
Make a 'raw/templates' directory with the command (UNIX systems):
mkdir -p raw/templates
Files in the raw directory are called raw files, files in the templates directory are called templates.
Enter into the raw directory and start writing a new file called 'p.raw'.
p.raw
@HEAD@
@TAIL@
$Date$
<HTML> <HEAD> <TITLE>Generated from p.raw</TITLE> </HEAD> <BODY> <H1>Generated from p.raw</H1> </BODY> </HTML>
As you can see p.raw resemble a common html file except from the first three lines.
Generate the '../p.html' file with the command
wpp p.raw
Suppose you want to change the "Generated from p.raw" title it into "My First Page", you have to write it twice. You could use 'sed' but if you don't know it or don't want to use it the best solution is probably to use wpp.
p.raw
@HEAD@
@TAIL@
$Date$
@TITLE=My First Page@ <HTML> <HEAD> <TITLE>@TITLE@</TITLE> </HEAD> <BODY> <H1>@TITLE@</H1> </BODY> </HTML>
In the fourth line we have declared a simple variable called TITLE, so every time you want to change the title of p.raw you should edit it once.
Step 2: Using templates [ ^ ]
You may need to write two or more file with common header and footer (except from title or something else).
By default WPP include a file 'templates/head.tmpl' after the $Date$ tag and 'templates/tail.tmpl' when reach the end of the raw file.
In the first step we have used the @HEAD@ and @TAIL@ directives in order to avoid to include them.
Modify p.raw and create 'templates/head.tmpl' and 'templates/tail.tmpl'.
p.raw
@TITLE=My First Page@
$Date$
This is an example page.
...
templates/head.tmpl
<HTML>
<HEAD>
<TITLE>@TITLE@</TITLE>
</HEAD>

<BODY>
<H1>@TITLE@</H1>
templates/tail.tmpl
Author: jack@AT@hide
</BODY>
</HTML>
The template is simply an html fragment that may contain variables and if conditions, as you can do in a .raw file.
Including an html fragment is quite simple, write it into a file in the templates directory and call it fragment.tmpl (don't forget the '.tmpl' extension).
To include the template use the @INCLUDE fragment@ directive (here you must omit the 'templates' directory and the '.tmpl' extension).
Into the templates directory you can create other directories, i.e. in order to include 'templates/dir/fragment.tmpl' simply use @INCLUDE dir/fragment@.
Step 3: The config files and the conditional generation [ ^ ]
When wpp is started it first look into the raw directory for a file called 'config' (this is the default, you can specify a different file with the config file switch).
Here you can put common variables and use different config files for conditional generation of files.
In example you could create a file called ctest.raw:
ctest.raw
$Date$
...
@IF SHOW_IMAGES@
  <IMG SRC="images/ctest.gif">
@ENDIF@
...
Now write three config files:
config
@INCLUDECFG config.common@
config.common
@SHOW_IMAGES=y@
... other common vars ...
config.noimg
@SHOW_IMAGES=@
The last two configs contains an @INCLUDECFG config.common@ directive and a variable declaration '@SHOW_IMAGES=y@' in 'config'.
Now if you run
wpp -c=config.noimg ctest.raw
It will generate '../ctest.html' without images.
You can set the DEFAULT_OUTPUTDIR to something different from the defaul '..', i.e. '../noimg.version/' into config.noimg. This allows you to create separate versions of 'ctest.html'.
^ Top < Previous     Next >