Made parseTemplate recursively replace template variables.