Пример #1
0
 def test_jinja2(self):
     """ Test jinja2 template renderer """
     signup = Template(
         u'Hello {{ user }} °C',
         'You are signed up -- <img src="cid:flower.jpg" /> {{ domain }}\n',
         attachments=[
             ImageAttachment('flower.jpg', b'\xff\xd8\xff\xe0\x00\x10JFIF', 'inline'),
         ],
         defaults=dict(domain='localhost')
     )
     signup.set_renderer(Jinja2TemplateRenderer)
     self._check_signup_template(signup)
Пример #2
0
 def test_template(self):
     """ Test Template """
     signup = Template(
         u'Hello $user °C',
         'You are signed up -- <img src="cid:flower.jpg" /> $domain\n',
         attachments=[
             ImageAttachment('flower.jpg', b'\xff\xd8\xff\xe0\x00\x10JFIF', 'inline'),
         ],
         defaults=dict(domain='localhost')
     )
     self._check_signup_template(signup)
Пример #3
0
    def get_template(self, name):
        path = os.path.join(self.januapath, 'mail_template',
                            self.config.mail_language.upper(), name)
        if not os.path.exists(path):
            raise MailError('Template %s not found' % name)

        template = Template.from_directory(path,
                                           subject_name='subject.txt',
                                           text_name='body.txt',
                                           html_name='body.html')
        template.set_renderer(UnicodePythonTemplateRenderer)
        return template
Пример #4
0
 def test_from_directory(self):
     """ Test Template.from_directory() """
     signup = Template.from_directory('tests/data/signup')
     signup.defaults(dict(domain='localhost'))
     self._check_signup_template(signup)