I have worked it out using the sourcecode.

To retrieve variables in forms from your process, you can use two Freemarker variables:
 - Task is for human task information fields. Take a look at the Task class and the TaskData class to see what you can access from your template.#
This way you can also get to your task metadata like:
${task.taskData.createdOn?datetime} would get the date the task was created.

 - Content is for your own mapped fields.
You will have to make a dataInputAssociaton that has the name of "Content" and use a dataInputAssociation to provide it with a HashMap of the values you want to be available in your template. The HashMap you put into content is accessible by content.<keyName> from the template.

Is this the official way to do it or is there a better way?

Thanks.
Sam Squire
This message may contain confidential and privileged information and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorised. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator and then immediately delete this message. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses.

Please refer to http://www.bnymellon.com/disclaimer/piml.html for certain disclosures.