# Templater class

(Shortest import: `from brian2.codegen.templates import Templater)`

class brian2.codegen.templates.Templater(package_name, extension, env_globals=None, templates_dir='templates')

  Bases: `object`

  Class to load and return all the templates a `CodeObject` defines.

  Parameters:

    package_name : str, tuple of str

    > The package where the templates are saved. If this is a tuple then each template will be searched in order starting from the first package in the tuple until the template is found. This allows for derived templates to be used. See also `derive`.

    extension : str

    > The file extension (e.g. `.pyx`) used for the templates.

    env_globals : dict (optional)

    > A dictionary of global values accessible by the templates. Can be used for providing utility functions. In all cases, the filter ‘autoindent’ is available (see existing templates for example usage).

    templates_dir : str, tuple of str, optional

    > The name of the directory containing the templates. Defaults to `'templates'`.

  Notes

  Templates are accessed using `templater.template_base_name` (the base name is without the file extension). This returns a `CodeObjectTemplate`.

  Methods

  `derive`(package_name[, extension, ...]) | Return a new Templater derived from this one, where the new package name and globals overwrite the old.

  Details

  derive(package_name, extension=None, env_globals=None, templates_dir='templates')

    Return a new Templater derived from this one, where the new package name and globals overwrite the old.