apachesubst - Template engine for Apache HTTPD configuration files
apachesubst provides a trivial way to generate configuration files from templates.
- Easy to learn: Simple syntax (Tcl syntax)
- Easy to use: Generate site configurations from templates in seconds
- Powerful: Change all generated config files by changing its template
- Flexible: Can be used to generate arbitrary configuration files. (not limited to apache)
- Unobtrusive: Can be used with manually managed configuration files.
- Slim: Less than 100 Lines-of-Code. Check it out yourself.
- Tcl 8.5 or later
- fileutil (usually installed with tcllib)
apachesubst.tcl to your apache
sites-available directory, e.g.
- Take a look at the examples:
A template file consists of text and Tcl commands. Tcl commands are enclosed in square brackets
This is a [return "test"].
This alone would be a sufficient template engine by itself. In order to make repetitive tasks even more convenient, a few commands have been defined (see 'Extra Commands' below).
substitute ...: apply arguments to templating/substitution process
include <filename>: include template file. usually used to include templates
include_raw <filename>: include file as is
raw <data>: use as is
define_template <name> <data>: define template
use_template <name> ...: use template with arguments as defined
value <varname> <default>: use variable if available, or otherwise default value
include_template_args [<num=0>]: use inside
define_templatedefinition: insert argument