def ensure_valid(self) -> None:
    'Return if template is valid.'
    if (self.is_static or (self._compiled_code is not None)):
        return
    try:
        self._compiled_code = self._env.compile(self.template)
    except jinja2.TemplateError as err:
        raise TemplateError(err) from err
Return if template is valid.
def ensure_valid(self) -> None:
    
    if (self.is_static or (self._compiled_code is not None)):
        return
    try:
        self._compiled_code = self._env.compile(self.template)
    except jinja2.TemplateError as err:
        raise TemplateError(err) from err