def template(self, template):
        if template is not None:
            if self.template_dir is None:
                raise RuntimeError("Please set 'template_dir' first")
            filename = _validate_template_filename(template)
            template = self.template_dir / filename
        self._template = template