*exception?*jinja2.TemplateError(*message=None*)[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.TemplateError "Permalink to this definition")
Baseclass for all template errors.
*exception?*jinja2.UndefinedError(*message=None*)[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.UndefinedError "Permalink to this definition")
Raised if a template tries to operate on?[Undefined](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.Undefined "jinja2.Undefined").
*exception?*jinja2.TemplateNotFound(*name*,?*message=None*)[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.TemplateNotFound "Permalink to this definition")
Raised if a template does not exist.
*exception?*jinja2.TemplatesNotFound(*names=()*,?*message=None*)[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.TemplatesNotFound "Permalink to this definition")
Like?[TemplateNotFound](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.TemplateNotFound "jinja2.TemplateNotFound")?but raised if multiple templates are selected. This is a subclass of?[TemplateNotFound](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.TemplateNotFound "jinja2.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*)[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.TemplateSyntaxError "Permalink to this definition")
Raised to tell the user that there is a problem with the template.
message[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.TemplateSyntaxError.message "Permalink to this definition")
錯誤信息的 utf-8 字節串。
lineno[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.TemplateSyntaxError.lineno "Permalink to this definition")
發生錯誤的行號。
name[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.TemplateSyntaxError.name "Permalink to this definition")
模板的加載名的 unicode 字符串。
filename[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.TemplateSyntaxError.filename "Permalink to this definition")
加載的模板的文件名字節串,以文件系統的編碼(多是 utf-8 , Windows 是 mbcs )。
文件名和錯誤消息是字節串而不是 unicode 字符串的原因是,在 Python 2.x 中,不對異常和回溯使用 unicode ,編譯器同樣。這會在 Python 3 改變。
*exception?*jinja2.TemplateAssertionError(*message*,?*lineno*,?*name=None*,*filename=None*)[](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.TemplateAssertionError "Permalink to this definition")
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](http://docs.jinkan.org/docs/jinja2/api.html#jinja2.TemplateSyntaxError "jinja2.TemplateSyntaxError")?and has the same attributes.
- 介紹
- 預備知識
- 安裝
- 基本 API 使用
- 實驗性的 Python 3 支持
- API
- 基礎
- Unicode
- 高層 API
- 自動轉義
- 標識符的說明
- 未定義類型
- 上下文
- 加載器
- 字節碼緩存
- 實用工具
- 異常
- 自定義過濾器
- 求值上下文
- 自定義測試
- 全局命名空間
- 低層 API
- 元 API
- 沙箱
- API
- 運算符攔截
- 模板設計者文檔
- 概要
- 變量
- 過濾器
- 測試
- 注釋
- 空白控制
- 轉義
- 行語句
- 模板繼承
- HTML 轉義
- 控制結構清單
- 導入上下文行為
- 表達式
- 內置過濾器清單
- 內置測試清單
- 全局函數清單
- 擴展
- 自動轉義擴展
- 擴展
- 添加擴展
- i18n 擴展
- 表達式語句
- 循環控制
- With 語句
- 自動轉義擴展
- 編寫擴展
- 集成
- Babel 集成
- Pylons
- TextMate
- Vim
- 從其它的模板引擎切換
- Jinja1
- Django
- Mako
- 提示和技巧
- Null-Master 退回
- 交替的行
- 高亮活動菜單項
- 訪問父級循環