Hi Adam,
Building on Rich's answer, you could use the Canonize functionality here.
(Quoted from the User Manual)
Canonize
This command allows you to perform batch search and replace operations which are governed by a pre-defined file. The transformation file is itself a list of paired search and replace strings or grep patterns, one pair per line. Each search string (or pattern) is separated from its replace string (or pattern) by a literal tab, so if you want your searches or replacements to match or insert tabs, you must use the special character “\t” within the corresponding strings.
1. Create a foobar.txt file with the following content (with tab separators):
# -*- x-bbedit-canon-grep: 1; -*-
\A foo\n
\Z \nbar
2. Use menu Text > Canonize... on your front document using the foobar.txt file.
\A is a regular expression for beginning of document.
\Z is a regular expression for end of document.
Applying Canonize with the foobar.txt file adds "foo" on a new line at the beginning of the document
and a new line with "bar" at the end of the document.
You should be able to create a text factory on this bases.
HTH
Jean Jourdain