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
- Line based replacements
- Editable tag escape characters (multi character escapes allowed)
- Auto modification tracking to assemble only modified or uncompiled files
- Directory mode allows scanning an entire directory for content files to assemble
Usage
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):
template=./template-file-name
/$:KeyTagSectionName
...Multi-line key tag contents
Template file format:
/:KeyTagSectionName
...
Download
MD5 Sum: f5d9982ed251a25b895dd993d5150771
Example Template File: example-template.tat (4 KB)
Example Content File: example-content.tac (6 KB)
ta.py example-content.tc
Version History
-
Build 5: Fixed a trailing blank issue with replacement key lines. This same issue caused problems with processing content files created in Windows while on Linux.
(Current Build)
-
Build 4: Good working condition, supports directory assembling. Help incorrectly shows previous version number 1.1.1.3.
Script: ta.py (13 KB) Version 1.1.1.4
MD5 Sum: c3aecde9386df4de1d72a718f8d403da