Skip to content

Import jinja template from external file #74

@dalepotter

Description

@dalepotter

Hi, nice library!

Is it possible to import a template from an external file (for example template.html)? I've adapted the example code in the docs, but am getting a TypeError - see below.

If this is possible, I'm happy to send a pull request to extend the docs examples.

sendemail.py

import emails
from emails.template import JinjaTemplate as T

message = emails.html(
     subject=T('Payment Receipt No.{{ billno }}'),
     html=T(open('template.html')),
     mail_from=('ABC', 'robot@mycompany.com')
     )

r = message.send(...)

This gives:

$ python sendemail.py
Traceback (most recent call last):
... 
TypeError: Can't compile non template nodes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions