This is also a problem with the PRO version.
Having ampersand within any variable will crash the document beyond usability.
I've solved the issue by replacing the ampersand with & before calling addTemplateVariable.
IMHO all XML reserved characters will crash the document like < or >.
Looking forward for a small update to resolve the issue.
Kind regards,
Gregor Streng