BogBat is a simple 64 bit Windows command line program that takes a text file containing templates and a data file as input and generates an output file with each template replaced by data value defined in the data file.
This program is very simple. It just replaces templates with text values. There are no loops, no functions, no text processing and no intelligent handling of white space around templates. The program's simple nature led to the name: the Bog Basic template program.
Basic usage
The following command line shows the normal way to use BogBat.
BogBat -d:data-file -t:template-file -o:output-file
This causes BogBat to read a data file named data-file
and a template file named template-file
and to output a file named output-file
that results from replacing any templates in template-file
with data from data-file
.
You must provide a data file on the command line, but if either the template file or output file is not present then the template text is read from standard input and the output is sent to standard output. Of course, either standard input or standard output can be redirected so:
BogBat -d:data-file <template-file >output-file
works exactly the same as the previous example.
File formats
The data file must have entries of the form key=value
, with each entry on a different line. Blank lines and lines that begin with a #
character are ignored. Spaces before key
and between key
and =
are ignored. Spaces after the =
sign are significant and are included in value
.
Template files are simple text files that contain templates. By default templates are delimited by {{
and }}
symbol pairs. Any text inside the delimiters is taken to be one of the key
values in the data file. The whole template is replaced by the value
from the data file that corresponds to key
. For example, if we have a template file with content:
The {{ foo }} sat on the {{ bar }}.
And data file with content:
foo=cat
bar=mat
Then running BogBat with the two files above produces the output:
The cat sat on the mat.
If any Key
has no value after the =
sign, or if the key referenced in a template does not exist then the template is deleted from the output.
By default all input files are assumed to be in UTF-8 format (either with or without UTF-8 preambles) and the output file is written in UTF-8 without a preamble. The text file encodings and use of preambles can be overridden using command line options.
The {{
and }}
characters used to delimit templates can be altered using a command line option. This is useful since there is no method of including the opening delimiter literally in the output so changing to a different delimter that doesn't appear literally in the text is the only way round this.
Getting help
All the available command line options can be displayed using the command:
BogBat --help
The output from this file is comprehensive and will scroll out of the console window. The output is sent to standard error, so can't be paged by the more
command. You can however send the output to a text file using the following command:
BogBat --help 2>my-file.txt
Copyright and license
BogBat is copyright © 2025 by Peter Johnson. The program and its source code are released under the terms of the MIT License.