Posted by: devinmoore | March 12, 2007

Documentation to template toolkit output

If I produce a document that has data tables in the document, I would like to be able to output selected table(s) to template code via, i.e. the perl template toolkit. The field data is filled in by the data table, and the template generator could make use of various templates simultaneously to save me the trouble of coding so much. This way, when I create documentation for a project on databases, for example, i could also simultaneously produce useful chunks of code for the database.

I am not looking to recreate, build, or maintain the system automatically, those are all far too complicated and invite many other complications. I just want to minimize the amount of bulk typing/copy-and-pasting one has to do to produce similar code over and over.

Drawbacks to this design are that not that much code is really reusable, so you’d end up with a ton of templates that maybe got used 2-3 times, versus a smaller number that were really reusable a lot. However, if the template library was shared amongst a large population of coders, the likelihood that a given template would be reused increases (provided that the template is preview-able… no one would use another person’s template(s) if they couldn’t preview the results).

Inevitably, the users of the template library would have to document their template so that other people understood its purpose, because a very large library would require too much previewing in order to find the template you’re looking for. Again, once it reaches a critical mass, this documentation becomes much more user-friendly. At first, it would seem cumbersome, but after 5-10 years of regular use, you’d have a vast array of indexed code block generators that deliver human meaning to their users. A lot of code generators lack this documentation, so you’re left with complex, unruly structures being generated without much meaning.

It’s much more useful to have a well-documented set of simpler structures generated (i.e. many versions of “<xml name>xml value</xml name>”). Complex structures usually have to be hand-generated anyhow because of customization issues. If the simple stuff were easier to generate without wearing one’s hands out from typing, you’d have more time to work on the complex structure parts.


Leave a response

You must be logged in to post a comment.

Categories