Usage from within an application

Templates are always part of a Collection in a Domain, i.e. the Domain and default Collection instances are always created, be it explicitly or implicitly. The preferred way to load/retrieve a Template is via a Domain instance (if necessary this implicitly creates a default Collection instance):

domain = Domain("/home/user/templates") t = domain.get_template("snap.html") print t.evoque(vars())

It may sometimes be more convenient to instantiate directly (if necessary this implicitly creates both Domain and default Collection instances):

t = Template("/home/user/templates", "snap.html") print t.evoque(vars())

Evoque is conceived with safety and security in mind. Under no circumstances, for example, is it ever possible to evoque a template from a file that is not within a declared collection. Given that there is no special distinction between templates and content, template collection root directories are treated in the same way that a web server treats its document-root.

Other notes

Given a template instance, you can always get the associated collection and domain with:

template.collection template.collection.domain

To create the (default) collection first, thus having an opportunity to name it explicitly, you do:

from evoque.collection import Collection collection = Collection(None, "default_c", "/home/user/templates") domain = collection.domain assert collection is domain.get_collection("default_c") assert collection is domain.get_collection()