A minimalist template engine for Python
The goal of Stencil is to provide just enough of a template engine in a single file.
Currently weighs in at just under 500 LoC
Make a directory for our templates:
$ mkdir tmpl
Create a simple template:
Good morning, {{ name|escape }}!
Write a script to use it
import stencil from .utils import escape stencil.FILTERS['escape'] = escape loader = stencil.TemplateLoader(['tmpl/']) t = loader['index.html'] c = stencil.Contxt({'name': 'Ruprect'}) print t.render(c) # Should output "Good morning, Ruprect!"
See the documentation to see more details.