In essence, configuration templates are PHP files which, when executed, output web server configuration files. The templates are executed in the environment where the specific variables $VAR and $OPT are available.
$VAR is an object containing the data model which should be applied to a template. The variable contains an essential set of parameters defining the content of web server configuration. The detailed structure of the array is presented in the Appendix C.
The most important function is IncludeTemplate() which is part of the $VAR array. The function allows including templates one into another, and it is defined as
where
$templateName - string denoting name of included template. Required
$OPT - an associative array which passes values to a template. Optional
$metainfo - an associative array which defines certain aliases in the template context. Optional
The basic function usage is as follows:
A text generated by the included template (server/tomcat.php) will be included in the configuration file.
In cases when the text generated by an included template should depend on the context, for example, when iterating over a set of values, it is possible to pass additional parameters to the template.
Here, we included the service/php.php template and passed the value 'enabled' => false to it. In the template being included the passed value is available in the variable $OPT:
The code in this sample will generate two different blocks of text depending on which value of the 'enabled' parameter is passed.
Note that $VAR, which contains the data model, can be used in templates being included as well. Some values of $VAR are defined using the content of $metainfo. For details on possible $metainfo content and how it affects a template context, refer to Appendix C. For example, by defining the subDomainId value in the $metainfo parameter, it is possible to set an exact subdomain model available at $VAR->subDomain in a template being included: