I have a variety of Velocity template files that represent e-mail messages. I am searching for an elegant way to allow the template file to output a subject line for the message as well as the contents. I have considered a few options:
Make the first line of the output something like "Subject: Bla" and strip it out in the Java. I have rejected this approach because performing fancy string manipulation from Java is exactly the problem I'm trying to solve by using Velocity in the first place.
Throw a settable object into the mapping for some code in the Velocity macro to call a setter on. Pros: Pretty simple. Cons: I dislike the idea of setting external objects from Velocity, even as just a form of output. It might be an unreasonable dislike, though.
Create some custom Velocity command, like #setSubjectLine. Pros: More elegant. Cons: Would apply as a valid command to all of my templates, regardless of whether they're e-mails or not.
Have separate template files for the subject line and the rest of the email. Pro: No special tricks at all! Con: Not all email logic lives in the same place.
Some cool Velocity trick I don't know.
???
So what should I do? Do you have a suggestion for 5 or 6? A reason I should choose 1, 2, 3, or 4?