Templating: added validation for allowed characters in variable names, Closes #1106