added setTemplate to set template from a string