def render(self, msg, render_format, lang): """ This basic renderer just returns the subject in the Msg payload """ if not self.can_render_format(render_format): NotImplementedError() if not self.underscore_template: template_url_path = self.get_template_path(render_format) template_url_path = template_url_path.replace(static(''), '') underscore_filepath = finders.AppDirectoriesFinder().find( template_url_path) if not underscore_filepath: err_msg = ( 'Could not resolve Underscore static url path {url_path} ' 'to a filesystem path.').format(url_path=template_url_path) raise Exception(err_msg) with open(underscore_filepath, "r") as _file: template_string = _file.read() self.underscore_template = us.template(template_string) _payload = copy.deepcopy(msg.payload) created_str = msg.created.strftime( "%B %d, %Y") + ' at ' + msg.created.strftime("%H:%M%p") + ' GMT' _payload.update({'__display_created': created_str}) return self.underscore_template(_payload)
def render(self, msg, render_format, lang): """ This basic renderer just returns the subject in the Msg payload """ if not self.can_render_format(render_format): NotImplementedError() if not self.underscore_template: template_url_path = self.get_template_path(render_format) template_url_path = template_url_path.replace(static(''), '') underscore_filepath = finders.AppDirectoriesFinder().find(template_url_path) if not underscore_filepath: err_msg = ( 'Could not resolve Underscore static url path {url_path} ' 'to a filesystem path.' ).format(url_path=template_url_path) raise Exception(err_msg) with open(underscore_filepath, "r") as _file: template_string = _file.read() self.underscore_template = us.template(template_string) _payload = copy.deepcopy(msg.payload) created_str = msg.created.strftime("%B %d, %Y") + ' at ' + msg.created.strftime("%H:%M%p") + ' GMT' _payload.update({ '__display_created': created_str }) return self.underscore_template(_payload)
def generate_email(participants): email_template = _.template('Dear <%= name %>,\n\r Welcome to this year\'s Secret Santa!! Below you will find the details of your chosen recipient. \n \n' + 'Name: <%= name %>\n\nThey enjoy <%= enjoy %>, their favorite holiday snack is <%= fav_holiday_snack %> and their preferred holiday if <%= holiday %>. \nTheir random other is <%= other %>') for person in participants: person.email_text = email_template(vars(person))
def generate_text(participants): sms_template = _.template('Hey <%= name %>,\n 2015 GBL Secret Santa details have been sent out. Please check your email! \n -Santa') for person in participants: person.sms_text = sms_template(vars(person))