Templates (uTemplate)

class microdot.utemplate.Template(template)

A template object.

Parameters:

template – The filename of the template to render, relative to the configured template directory.

classmethod initialize(template_dir='templates', loader_class=<class 'utemplate.recompile.Loader'>)

Initialize the templating subsystem.

Parameters:
  • template_dir – the directory where templates are stored. This argument is optional. The default is to load templates from a templates subdirectory.

  • loader_class – the utemplate.Loader class to use when loading templates. This argument is optional. The default is the recompile.Loader class, which automatically recompiles templates when they change.

name

The name of the template

generate(*args, **kwargs)

Return a generator that renders the template in chunks, with the given arguments.

render(*args, **kwargs)

Render the template with the given arguments and return it as a string.

generate_async(*args, **kwargs)

Return an asynchronous generator that renders the template in chunks, using the given arguments.

async render_async(*args, **kwargs)

Render the template with the given arguments asynchronously and return it as a string.