Plain is headed towards 1.0! Subscribe for development updates →

Templates

Render HTML templates using Jinja.

Templates are typically rendered in TemplateViews, but you can also render them directly to strings for emails or other use cases.

from plain.templates import Template


Template("comment.md").render({
    "message": "Hello, world!",
})

Template files can be located in either a root app/templates, or the templates directory in any installed packages.

Customizing Jinja

 1from .core import Template, TemplateFileMissing
 2from .jinja import (
 3    register_template_extension,
 4    register_template_filter,
 5    register_template_global,
 6)
 7
 8__all__ = [
 9    "Template",
10    "TemplateFileMissing",
11    # Technically these are jinja-specific,
12    # but expected to be used pretty frequently so
13    # the shorter import is handy.
14    "register_template_extension",
15    "register_template_filter",
16    "register_template_global",
17]