Skip to main content.

Template Assembler

About

Template Assembler is a general purpose text templating script created in Python. It allows you to create a template file with redundant text and tags where text will later be entered. The text represented by the tags are specified in a separate content file. Another project created out of necessity. I use the Template Assembler to generate the web pages you see here.

A simple example:

You have 5 text files that have similar content, only a few lines are different. You create a template file with all the content which is the files will have in common. In this template files, where the differing text will be you add a named tag, such as:

/:MyVaryingContent

You then make a content file for each of the 5 files which only defines what 'MyVaryingContent' is. Run the Template Assembler and produce the full resulting files.

Features

Usage

ta.py [-f] [-i] [-d] <Content File/Directory> [<Explicit Output File Name>]

h - Show help.
f - Force update. Ignores modified stamp and always assembles.
i - Ignore errors. Continues processing next file when failure
    occurs, instead of aborting the operation.
d - Directory mode. Directory is specified to process all content
    files with the correct file extension.
r - Recursive directory mode. Same as directory mode, but searches the
    directory and it's sub directories.

Content File format (default .tc extension):
output=./output-file-name
template=./template-file-name
/$:KeyTagSectionName
    ...Multi-line key tag contents

Template file format:
...
/:KeyTagSectionName
...

Download

Python Script: ta.py (12.9 KB) Version 1.1.1.5
MD5 Sum: f5d9982ed251a25b895dd993d5150771

Example Template File: example-template.tat (4 KB)
Example Content File: example-content.tac (6 KB)
To compile with ta.py in same directory with both example files:
  ta.py example-content.tc

Version History