Jinja2 API

Table of Contents

  • Introduction
    • Prerequisites
    • Installation
      • As a Python egg (via easy_install)
      • From the tarball release
      • Installing the development version
      • MarkupSafe Dependency
    • Basic API Usage
    • Experimental Python 3 Support
  • Template Designer Documentation
    • 1. Synopsis
    • 2. Variables
    • 3. Filters
    • 4. Tests
    • 5. Comments
    • 6. Whitespace Control
    • 7. Escaping
    • 8. Line Statements
    • 9. Template Inheritance
      • 9.1. Base Template
      • 9.2. Child Template
      • 9.3. Super Blocks
      • 9.4. Named Block End-Tags
      • 9.5. Block Nesting and Scope
      • 9.6. Template Objects
    • 10. HTML Escaping
      • 10.1. Working with Manual Escaping
      • 10.2. Working with Automatic Escaping
    • 11. List of Control Structures
      • 11.1. For
      • 11.2. If
      • 11.3. Macros
      • 11.4. Call
      • 11.5. Filters
      • 11.6. Assignments
      • 11.7. Block Assignments
      • 11.8. Extends
      • 11.9. Blocks
      • 11.10. Include
      • 11.11. Import
    • 12. Import Context Behavior
    • 13. Expressions
      • 13.1. Literals
      • 13.2. Math
      • 13.3. Comparisons
      • 13.4. Logic
      • 13.5. Other Operators
      • 13.6. If Expression
    • 14. List of Builtin Filters
    • 15. List of Builtin Tests
    • 16. List of Global Functions
    • 17. Extensions
      • 17.1. i18n
      • 17.2. Expression Statement
      • 17.3. Loop Controls
      • 17.4. With Statement
    • 18. Autoescape Extension
  • Extensions
    • 1. Adding Extensions
    • 2. i18n Extension
      • 2.1. Environment Methods
      • 2.2. Newstyle Gettext
    • 3. Expression Statement
    • 4. Loop Controls
    • 5. With Statement
    • 6. Autoescape Extension
  • Others from the official doc
    • 1. API
      • 1.1. Basics
      • 1.2. Unicode
      • 1.3. High Level API
        • 1.3.1. Environment
        • 1.3.2. Template
        • 1.3.3. jinja2.environment.TemplateStream
      • 1.4. Autoescaping
      • 1.5. Notes on Identifiers
      • 1.6. Undefined Types
        • 1.6.1. Undefined
        • 1.6.2. DebugUndefined
        • 1.6.3. StrictUndefined
        • 1.6.4. make_logging_undefined()
      • 1.7. The Context
        • 1.7.1. jinja2.runtime.Context
      • 1.8. Loaders
        • 1.8.1. jinja2.BaseLoader
        • 1.8.2. jinja2.FileSystemLoader
        • 1.8.3. jinja2.PackageLoader
        • 1.8.4. jinja2.DictLoader
        • 1.8.5. jinja2.FunctionLoader
        • 1.8.6. jinja2.PrefixLoader
        • 1.8.7. jinja2.ChoiceLoader
        • 1.8.8. jinja2.ModuleLoader
      • 1.9. Bytecode Cache
        • 1.9.1. jinja2.BytecodeCache
        • 1.9.2. jinja2.bccache.Bucket
        • 1.9.3. jinja2.FileSystemBytecodeCache
        • 1.9.4. jinja2.MemcachedBytecodeCache
      • 1.10. Utilities
        • 1.10.1. jinja2.environmentfilter()
        • 1.10.2. jinja2.contextfilter()
        • 1.10.3. jinja2.evalcontextfilter()
        • 1.10.4. jinja2.environmentfunction()
        • 1.10.5. jinja2.contextfunction()
        • 1.10.6. jinja2.evalcontextfunction()
        • 1.10.7. escape(s)
        • 1.10.8. jinja2.clear_caches()
        • 1.10.9. jinja2.is_undefined()
        • 1.10.10. jinja2.Markup
      • 1.11. Exceptions
        • 1.11.1. jinja2.TemplateError
        • 1.11.2. jinja2.UndefinedError
        • 1.11.3. jinja2.TemplateNotFound
        • 1.11.4. jinja2.TemplatesNotFound
        • 1.11.5. jinja2.TemplateSyntaxError
        • 1.11.6. jinja2.TemplateAssertionError
      • 1.12. Custom Filters
      • 1.13. Evaluation Context
        • 1.13.1. jinja2.nodes.EvalContext
      • 1.14. Custom Tests
      • 1.15. The Global Namespace
      • 1.16. Low Level API
      • 1.17. The Meta API
    • 2. Sandbox
      • 2.1. API
        • 2.1.1. SandboxedEnvironment
        • 2.1.2. ImmutableSandboxedEnvironment
        • 2.1.3. SecurityError
        • 2.1.4. unsafe()
        • 2.1.5. is_internal_attribute()
        • 2.1.6. modifies_known_mutable()
      • 2.2. Operator Intercepting
    • 3. Writing Extensions
      • 3.1. Example Extension
      • 3.2. Extension API
        • 3.2.1. jinja2.ext.Extension
      • 3.3. Parser API
        • 3.3.1. jinja2.parser.Parser
        • 3.3.2. jinja2.lexer.TokenStream
        • 3.3.3. jinja2.lexer.Token
        • 3.3.4. jinja2.lexer.count_newlines
      • 3.4. AST
    • 4. Integration
      • 4.1. Babel Integration
      • 4.2. Pylons
      • 4.3. TextMate
      • 4.4. Vim
    • 5. Switching from other Template Engines
      • 5.1. Jinja1
        • 5.1.1. API
        • 5.1.2. Templates
      • 5.2. Django
        • 5.2.1. Method Calls
        • 5.2.2. Filter Arguments
        • 5.2.3. Tests
        • 5.2.4. Loops
        • 5.2.5. Cycle
      • 5.3. Mako
    • 6. Tips and Tricks
      • 6.1. Null-Master Fallback
      • 6.2. Alternating Rows
      • 6.3. Highlighting Active Menu Items
      • 6.4. Accessing the parent Loop
    • 7. Frequently Asked Questions
      • 7.1. Why is it called Jinja?
      • 7.2. How fast is it?
      • 7.3. How Compatible is Jinja2 with Django?
      • 7.4. Isn’t it a terrible idea to put Logic into Templates?
      • 7.5. Why is Autoescaping not the Default?
      • 7.6. Why is the Context immutable?
      • 7.7. My tracebacks look weird. What’s happening?
      • 7.8. Why is there no Python 2.3/2.4/2.5/3.1/3.2 support?
      • 7.9. My Macros are overridden by something

Auto-generated API

  • jinja2
    • Nutshell
    • Functions
      • jinja2.clear_caches
      • jinja2.contextfilter
      • jinja2.contextfunction
      • jinja2.environmentfilter
      • jinja2.environmentfunction
      • jinja2.escape
      • jinja2.evalcontextfilter
      • jinja2.evalcontextfunction
      • jinja2.is_undefined
      • jinja2.make_logging_undefined
    • Classes
      • jinja2.BaseLoader
        • Methods
        • Attributes
      • jinja2.BytecodeCache
        • Methods
      • jinja2.ChoiceLoader
        • Methods
        • Attributes
      • jinja2.DebugUndefined
        • Methods
      • jinja2.DictLoader
        • Methods
        • Attributes
      • jinja2.Environment
        • Methods
        • Attributes
      • jinja2.FileSystemBytecodeCache
        • Methods
      • jinja2.FileSystemLoader
        • Methods
        • Attributes
      • jinja2.FunctionLoader
        • Methods
        • Attributes
      • jinja2.Markup
        • Methods
      • jinja2.MemcachedBytecodeCache
        • Methods
      • jinja2.ModuleLoader
        • Methods
        • Attributes
      • jinja2.PackageLoader
        • Methods
        • Attributes
      • jinja2.PrefixLoader
        • Methods
        • Attributes
      • jinja2.StrictUndefined
        • Methods
      • jinja2.Template
        • Methods
        • Attributes
      • jinja2.Undefined
        • Methods
    • Exceptions
      • jinja2.TemplateAssertionError
      • jinja2.TemplateError
      • jinja2.TemplateNotFound
      • jinja2.TemplateSyntaxError
      • jinja2.TemplatesNotFound
      • jinja2.UndefinedError
  • jinja2.sandbox
    • Functions
      • jinja2.sandbox.is_internal_attribute
      • jinja2.sandbox.modifies_known_mutable
      • jinja2.sandbox.safe_range
      • jinja2.sandbox.unsafe
    • Classes
      • jinja2.sandbox.DictMixin
        • Methods
      • jinja2.sandbox.Environment
        • Methods
        • Attributes
      • jinja2.sandbox.ImmutableSandboxedEnvironment
        • Methods
        • Attributes
      • jinja2.sandbox.MutableMapping
        • Methods
      • jinja2.sandbox.MutableSequence
        • Methods
      • jinja2.sandbox.MutableSet
        • Methods
      • jinja2.sandbox.SandboxedEnvironment
        • Methods
        • Attributes
      • jinja2.sandbox.Set
        • Methods
      • jinja2.sandbox.UserDict
        • Methods
      • jinja2.sandbox.UserList
        • Methods
      • jinja2.sandbox.deque
        • Methods
        • Attributes
    • Exceptions
      • jinja2.sandbox.SecurityError
  • jinja2.exceptions
    • Functions
      • jinja2.exceptions.implements_to_string
    • Classes
      • jinja2.exceptions.imap
        • Attributes
      • jinja2.exceptions.text_type
        • Methods
    • Exceptions
      • jinja2.exceptions.FilterArgumentError
      • jinja2.exceptions.SecurityError
      • jinja2.exceptions.TemplateAssertionError
      • jinja2.exceptions.TemplateError
      • jinja2.exceptions.TemplateNotFound
      • jinja2.exceptions.TemplateRuntimeError
      • jinja2.exceptions.TemplateSyntaxError
      • jinja2.exceptions.TemplatesNotFound
      • jinja2.exceptions.UndefinedError
  • jinja2.environment
    • Functions
      • jinja2.environment.concat
      • jinja2.environment.consume
      • jinja2.environment.copy_cache
      • jinja2.environment.create_cache
      • jinja2.environment.encode_filename
      • jinja2.environment.generate
      • jinja2.environment.get_lexer
      • jinja2.environment.get_next
      • jinja2.environment.get_spontaneous_environment
      • jinja2.environment.implements_iterator
      • jinja2.environment.implements_to_string
      • jinja2.environment.import_string
      • jinja2.environment.internalcode
      • jinja2.environment.iteritems
      • jinja2.environment.load_extensions
      • jinja2.environment.new_context
      • jinja2.environment.optimize
      • jinja2.environment.reduce
      • jinja2.environment.reraise
    • Classes
      • jinja2.environment.CodeGenerator
        • Methods
      • jinja2.environment.Context
        • Methods
        • Attributes
      • jinja2.environment.Environment
        • Methods
        • Attributes
      • jinja2.environment.EvalContext
        • Methods
      • jinja2.environment.LRUCache
        • Methods
      • jinja2.environment.Markup
        • Methods
      • jinja2.environment.Parser
        • Methods
      • jinja2.environment.Template
        • Methods
        • Attributes
      • jinja2.environment.TemplateExpression
        • Methods
      • jinja2.environment.TemplateModule
        • Methods
      • jinja2.environment.TemplateStream
        • Methods
      • jinja2.environment.TokenStream
        • Methods
        • Attributes
      • jinja2.environment.Undefined
        • Methods
      • jinja2.environment.ifilter
        • Attributes
      • jinja2.environment.imap
        • Attributes
      • jinja2.environment.text_type
        • Methods
    • Exceptions
      • jinja2.environment.TemplateNotFound
      • jinja2.environment.TemplateRuntimeError
      • jinja2.environment.TemplateSyntaxError
      • jinja2.environment.TemplatesNotFound
  • jinja2.runtime
    • Functions
      • jinja2.runtime.concat
      • jinja2.runtime.escape
      • jinja2.runtime.identity
      • jinja2.runtime.implements_iterator
      • jinja2.runtime.implements_to_string
      • jinja2.runtime.internalcode
      • jinja2.runtime.iteritems
      • jinja2.runtime.make_logging_undefined
      • jinja2.runtime.markup_join
      • jinja2.runtime.new_context
      • jinja2.runtime.object_type_repr
      • jinja2.runtime.soft_unicode
      • jinja2.runtime.unicode_join
    • Classes
      • jinja2.runtime.BlockReference
        • Methods
        • Attributes
      • jinja2.runtime.Context
        • Methods
        • Attributes
      • jinja2.runtime.DebugUndefined
        • Methods
      • jinja2.runtime.EvalContext
        • Methods
      • jinja2.runtime.LoopContext
        • Methods
        • Attributes
      • jinja2.runtime.LoopContextIterator
        • Methods
        • Attributes
      • jinja2.runtime.Macro
        • Methods
      • jinja2.runtime.Mapping
        • Methods
      • jinja2.runtime.Markup
        • Methods
      • jinja2.runtime.StrictUndefined
        • Methods
      • jinja2.runtime.TemplateReference
        • Methods
      • jinja2.runtime.Undefined
        • Methods
      • jinja2.runtime.chain
        • Methods
        • Attributes
      • jinja2.runtime.imap
        • Attributes
      • jinja2.runtime.text_type
        • Methods
      • jinja2.runtime.to_string
        • Methods
    • Exceptions
      • jinja2.runtime.TemplateNotFound
      • jinja2.runtime.TemplateRuntimeError
      • jinja2.runtime.UndefinedError
  • jinja2.bccache
    • Functions
      • jinja2.bccache.BytesIO
      • jinja2.bccache.listdir
      • jinja2.bccache.marshal_dump
      • jinja2.bccache.marshal_load
      • jinja2.bccache.open_if_exists
      • jinja2.bccache.sha1
    • Classes
      • jinja2.bccache.Bucket
        • Methods
      • jinja2.bccache.BytecodeCache
        • Methods
      • jinja2.bccache.FileSystemBytecodeCache
        • Methods
      • jinja2.bccache.MemcachedBytecodeCache
        • Methods
      • jinja2.bccache.text_type
        • Methods
  • jinja2.nodes
    • Functions
      • jinja2.nodes.get_eval_context
      • jinja2.nodes.with_metaclass
    • Classes
      • jinja2.nodes.Add
        • Methods
        • Attributes
      • jinja2.nodes.And
        • Methods
        • Attributes
      • jinja2.nodes.Assign
        • Methods
        • Attributes
      • jinja2.nodes.AssignBlock
        • Methods
        • Attributes
      • jinja2.nodes.BinExpr
        • Methods
        • Attributes
      • jinja2.nodes.Block
        • Methods
        • Attributes
      • jinja2.nodes.Break
        • Methods
        • Attributes
      • jinja2.nodes.Call
        • Methods
        • Attributes
      • jinja2.nodes.CallBlock
        • Methods
        • Attributes
      • jinja2.nodes.Compare
        • Methods
        • Attributes
      • jinja2.nodes.Concat
        • Methods
        • Attributes
      • jinja2.nodes.CondExpr
        • Methods
        • Attributes
      • jinja2.nodes.Const
        • Methods
        • Attributes
      • jinja2.nodes.ContextReference
        • Methods
        • Attributes
      • jinja2.nodes.Continue
        • Methods
        • Attributes
      • jinja2.nodes.Dict
        • Methods
        • Attributes
      • jinja2.nodes.Div
        • Methods
        • Attributes
      • jinja2.nodes.EnvironmentAttribute
        • Methods
        • Attributes
      • jinja2.nodes.EvalContext
        • Methods
      • jinja2.nodes.EvalContextModifier
        • Methods
        • Attributes
      • jinja2.nodes.Expr
        • Methods
        • Attributes
      • jinja2.nodes.ExprStmt
        • Methods
        • Attributes
      • jinja2.nodes.Extends
        • Methods
        • Attributes
      • jinja2.nodes.ExtensionAttribute
        • Methods
        • Attributes
      • jinja2.nodes.Filter
        • Methods
        • Attributes
      • jinja2.nodes.FilterBlock
        • Methods
        • Attributes
      • jinja2.nodes.FloorDiv
        • Methods
        • Attributes
      • jinja2.nodes.For
        • Methods
        • Attributes
      • jinja2.nodes.FromImport
        • Methods
        • Attributes
      • jinja2.nodes.Getattr
        • Methods
        • Attributes
      • jinja2.nodes.Getitem
        • Methods
        • Attributes
      • jinja2.nodes.Helper
        • Methods
        • Attributes
      • jinja2.nodes.If
        • Methods
        • Attributes
      • jinja2.nodes.Import
        • Methods
        • Attributes
      • jinja2.nodes.ImportedName
        • Methods
        • Attributes
      • jinja2.nodes.Include
        • Methods
        • Attributes
      • jinja2.nodes.InternalName
        • Methods
        • Attributes
      • jinja2.nodes.Keyword
        • Methods
        • Attributes
      • jinja2.nodes.List
        • Methods
        • Attributes
      • jinja2.nodes.Literal
        • Methods
        • Attributes
      • jinja2.nodes.Macro
        • Methods
        • Attributes
      • jinja2.nodes.MarkSafe
        • Methods
        • Attributes
      • jinja2.nodes.MarkSafeIfAutoescape
        • Methods
        • Attributes
      • jinja2.nodes.Markup
        • Methods
      • jinja2.nodes.Mod
        • Methods
        • Attributes
      • jinja2.nodes.Mul
        • Methods
        • Attributes
      • jinja2.nodes.Name
        • Methods
        • Attributes
      • jinja2.nodes.Neg
        • Methods
        • Attributes
      • jinja2.nodes.Node
        • Methods
        • Attributes
      • jinja2.nodes.NodeType
        • Methods
      • jinja2.nodes.Not
        • Methods
        • Attributes
      • jinja2.nodes.Operand
        • Methods
        • Attributes
      • jinja2.nodes.Or
        • Methods
        • Attributes
      • jinja2.nodes.Output
        • Methods
        • Attributes
      • jinja2.nodes.Pair
        • Methods
        • Attributes
      • jinja2.nodes.Pos
        • Methods
        • Attributes
      • jinja2.nodes.Pow
        • Methods
        • Attributes
      • jinja2.nodes.Scope
        • Methods
        • Attributes
      • jinja2.nodes.ScopedEvalContextModifier
        • Methods
        • Attributes
      • jinja2.nodes.Slice
        • Methods
        • Attributes
      • jinja2.nodes.Stmt
        • Methods
        • Attributes
      • jinja2.nodes.Sub
        • Methods
        • Attributes
      • jinja2.nodes.Template
        • Methods
        • Attributes
      • jinja2.nodes.TemplateData
        • Methods
        • Attributes
      • jinja2.nodes.Test
        • Methods
        • Attributes
      • jinja2.nodes.Tuple
        • Methods
        • Attributes
      • jinja2.nodes.UnaryExpr
        • Methods
        • Attributes
      • jinja2.nodes.deque
        • Methods
        • Attributes
      • jinja2.nodes.izip
        • Attributes
      • jinja2.nodes.text_type
        • Methods
    • Exceptions
      • jinja2.nodes.Impossible
  • jinja2.ext
    • Functions
      • jinja2.ext.babel_extract
      • jinja2.ext.concat
      • jinja2.ext.contextfunction
      • jinja2.ext.extract_from_ast
      • jinja2.ext.import_string
      • jinja2.ext.iteritems
      • jinja2.ext.with_metaclass
    • Classes
      • jinja2.ext.AutoEscapeExtension
        • Methods
        • Attributes
      • jinja2.ext.Environment
        • Methods
        • Attributes
      • jinja2.ext.ExprStmtExtension
        • Methods
        • Attributes
      • jinja2.ext.Extension
        • Methods
        • Attributes
      • jinja2.ext.ExtensionRegistry
        • Methods
      • jinja2.ext.InternationalizationExtension
        • Methods
        • Attributes
      • jinja2.ext.LoopControlExtension
        • Methods
        • Attributes
      • jinja2.ext.Markup
        • Methods
      • jinja2.ext.WithExtension
        • Methods
        • Attributes
      • jinja2.ext.autoescape
        • Methods
        • Attributes
      • jinja2.ext.do
        • Methods
        • Attributes
      • jinja2.ext.i18n
        • Methods
        • Attributes
      • jinja2.ext.loopcontrols
        • Methods
        • Attributes
      • jinja2.ext.with_
        • Methods
        • Attributes
    • Exceptions
      • jinja2.ext.TemplateAssertionError
      • jinja2.ext.TemplateSyntaxError
  • jinja2.lexer
    • Functions
      • jinja2.lexer.compile_rules
      • jinja2.lexer.count_newlines
      • jinja2.lexer.describe_token
      • jinja2.lexer.describe_token_expr
      • jinja2.lexer.get_lexer
      • jinja2.lexer.implements_iterator
      • jinja2.lexer.intern
      • jinja2.lexer.iteritems
    • Classes
      • jinja2.lexer.Failure
        • Methods
      • jinja2.lexer.LRUCache
        • Methods
      • jinja2.lexer.Lexer
        • Methods
      • jinja2.lexer.Token
        • Methods
        • Attributes
      • jinja2.lexer.TokenStream
        • Methods
        • Attributes
      • jinja2.lexer.TokenStreamIterator
        • Methods
      • jinja2.lexer.deque
        • Methods
        • Attributes
      • jinja2.lexer.itemgetter
      • jinja2.lexer.text_type
        • Methods
    • Exceptions
      • jinja2.lexer.TemplateSyntaxError
  • jinja2.parser
    • Functions
      • jinja2.parser.describe_token
      • jinja2.parser.describe_token_expr
    • Classes
      • jinja2.parser.Parser
        • Methods
      • jinja2.parser.imap
        • Attributes
    • Exceptions
      • jinja2.parser.TemplateAssertionError
      • jinja2.parser.TemplateSyntaxError
Jinja2 API
  • Docs »
  • <no title>
  • View page source

  • jinja2.runtime
jinja2.runtime jinja2.runtime
Next Previous

© Copyright 2016.

Built with Sphinx using a theme provided by Read the Docs.