This part of the documentation explains how to use and write a template loader.
Loads templates from the filesystem:
from jinja import Environment, FileSystemLoader e = Environment(loader=FileSystemLoader('templates/'))
You can pass the following keyword arguments to the loader on initialisation:
searchpath String with the path to the templates on the filesystem. use_memcache Set this to True to enable memory caching. This is usually a good idea in production mode, but disable it during development since it won't reload template changes automatically. This only works in persistent environments like FastCGI. memcache_size Number of template instance you want to cache. Defaults to 40. cache_folder Set this to an existing directory to enable caching of templates on the file system. Note that this only affects templates transformed into python code. Default is None which means that caching is disabled. auto_reload Set this to False for a slightly better performance. In that case Jinja won't check for template changes on the filesystem.
Template loaders are just normal Python classes that have to provide some functions used to load and translate templates. Here is a simple loader implementation you can use as the base for your own loader:
Once a loader is bound to an environment, you have to omit the environment argument for the public functions get_source, parse and load.