fix handling of percent symbols

Percent symbols seem to get truncated -- a simple test case is:

    print (100 % 3)

Basically, when the template is expanded, gsub is used -- and gsub expects percents in the replacement text to be wildcard references.  

Added a hack which fixes it for me, there may be much better ways of doing it!