Let’s start with an important question: what is the plural of Hello world? Is it Hello worlds? Anyway, I recently used pystache because I wanted something simpler than Jinja2. So, Thought it would be nice to compare small hello world for both engines.

pystache Link to heading

pystche is very simple to use. Just render and passing template and variable dict.

import pystache
template = "Hello World and {{ person }}"
template_txt = pystache.render(template, {'person': 'foobar'})
print(template_txt)

Jinja2 Link to heading

Jinja2 is slightly more complicated even for text replacement. It gets even more complicated with template loaders.

import jinja2
environment = jinja2.Environment()
template = environment.from_string("Hello world and {{ person }}")
template_txt = template.render(person="foobar")
print(template_txt)