I had thought of generalizing it further... but what other documents would be likely to use it? Most scripting languages should be using their native include/require commands instead of something like this, IMHO.
Hmm, you do have a very good point there. Perhaps it isn't needed.
However, something like this may be useful when writing code in a less flexible language and using scripting to help get around some of the repetition that is sometimes necessary...
Matthew