The template object contains several functions which can be used from template scripts to customize template behavior.
The following examples quickly illustrate some of the use:
To get a user-specified option:
docs = template.options.get('docs')
To get a user-specified option verified against a regular expression and with a default value:
template.options.get('docs', re.compile(r'(qb|qb\+doxyref|qb\+doxy)$'), 'qb+doxyref')
To get a boolean (y/n) user specified option with a default value:
template.options.get_boolean('vc8ide', False):
To set up a substitution template for file names:
template.name_replacement('$template_library$', library_name)
To set up a specific substitution template:
template.content_replacement(['.hpp', '.cpp'], '$template_created$', '// Created in $template_year$')
To set up a general substitution template:
template.general_content_replacement('$template_year$', str(time.localtime().tm_year))
To ignore (not process) an entire subdirectory in the same directory as the script:
template.ignore_subdirectory('vc8ide')
To ignore (not process) a file in the same directory as the script:
template.ignore_subfile('boostbook_doxygen.css')
To submit python-generated file content from a python template file:
content=""" This is a script-generated file.""" content += """ Yes it is.""" template.submit_content(content)
or
template.append_content(""" This is a script-generated file.""") template.append_content(""" Yes it is.""")