Macro.PL is a Perl script for automated generation of static web pages.
Formatting information can be placed in a global template file to be used
over a potentially large set of HTML pages.
Information exported from databases can be used to generate large sites or
frequently updated information displays.
Macro.PL performs recursive macro expansion in files.
Simple macro calls are inserted into the HTML source code with the form __MACRONAME__ - where MACRONAME can be any name consisting of letters/digits and the minus sign.
The contents of the macro is defined in the macro definition file or in the database table.
Macros may also have arguments, e.g. __MACRONAME__("argument text" __SECONDARG__) - where the first argument is a constant text and the second is another macro call.
Macro definition file:
A macro definition starts with the macro name on the first line, definitions can consist of multiple lines, separated by empty lines.
this is the replacement text
Macro with arguments:
argument one is __1__ and arg two is __2__ and so on
Macro names are case sensitive.
some other text __MACRONAME__ some other text
Macro with space separated arguments:
__MACRONAME__(argument1 argument2 ... )
All files in the source directory will be processed.
One set of files in the target directory will be generated for each occurence
of the trigger argument __EVAL__ in the macro definition file.
The file names for the output files are generated by appending the
contents of the __NAME__ macro to the source file name (extension remains
unchanged), e.g. file.html with __NAME__=one will become fileone.html
If option -t databasefile is given a tab separated tabular text database
file is used in addition to the macro definition file, one set of output
files for each row of the table.
Field delimiters " may be used for multiline field contents (escape with "").
The first line of the table is read for the macro names (macro names are
built by enclosing the names with __ symbols), e.g.
NAME field1 field3
myname text1 text2
If option -c categoryfield[:filenamefield] is given in addition
to option -t a single input file is used to generate category files.
A category is a consecutive number of rows where the contents of the
category field is the same.
One output file is generated for each category.
The output file name is either a 4 digit number starting with 0001
plus .html or the contents of the file name field (if specified)
The input file consists of header, loop, and footer part.
While header and footer parts will only be used once for each category
the loop part will be used once for each table row.
The loop part is defined to be between two lines containing __LOOP__ and
this is a loop text
This allows categorized tabular information to be converted into HTML
If option -i fieldname:fieldtext is given in addition to option -t
a table row is only processed if the table field fieldname equals
If option -f folderfield is given the ouput files are written to
a directory named with the contents of folderfield.
Option -v enables verbose error reporting - including non-existent macros.
macro.pl [-t database] [-c category[:name]] [-i field:text] [-f field] [-v] macrofile source targetdir
Table input, output to folders