update parseTemplates()

from
https://en.wikipedia.org/wiki/Wikipedia:Village_pump_%28technical%29/Archive_99#Template_parsing