Skip to content
Advertisement

light weight template engine for python

Which is the simplest and light weight html templating engine in Python which I can use to generate customized email newsletters.

Advertisement

Answer

For a really minor templating task, Python itself isn’t that bad. Example:

def dynamic_text(name, food):
    return """
    Dear %(name)s,
    We're glad to hear that you like %(food)s and we'll be sending you some more soon.
    """ % {'name':name, 'food':food}

In this sense, you can use string formatting in Python for simple templating. That’s about as lightweight as it gets.

If you want to go a bit deeper, Jinja2 is the most “designer friendly” (read: simple) templating engine in the opinion of many.

You can also look into Mako and Genshi. Ultimately, the choice is yours (what has the features you’d like and integrates nicely with your system).

3 People found this is helpful
Advertisement