异常
exception jinja2.TemplateError(message=None)
Baseclass for all template errors.
exception jinja2.UndefinedError(message=None)
Raised if a template tries to operate on Undefined.
exception jinja2.TemplateNotFound(name, message=None)
Raised if a template does not exist.
exception jinja2.TemplatesNotFound(names=(), message=None)
Like TemplateNotFound but raised if multiple templates are selected. This is a subclass of TemplateNotFound exception, so just catching the base exception will catch both.
New in version 2.2.
exception jinja2.TemplateSyntaxError(message, lineno, name=None,filename=None)
Raised to tell the user that there is a problem with the template.
错误信息的 utf-8 字节串。
发生错误的行号。
模板的加载名的 unicode 字符串。
加载的模板的文件名字节串,以文件系统的编码(多是 utf-8 , Windows 是 mbcs )。
文件名和错误消息是字节串而不是 unicode 字符串的原因是,在 Python 2.x 中,不对异常和回溯使用 unicode ,编译器同样。这会在 Python 3 改变。
exception jinja2.TemplateAssertionError(message, lineno, name=None,filename=None)
Like a template syntax error, but covers cases where something in the template caused an error at compile time that wasn’t necessarily caused by a syntax error. However it’s a direct subclass of TemplateSyntaxError and has the same attributes.
更多建议: