jinja2.lexer

jinja2.lexer

This module implements a Jinja / Python combination lexer. The Lexer class provided by this module is used to do some preprocessing for Jinja.

On the one hand it filters out invalid operators like the bitshift operators we don’t allow in templates. On the other hand it separates template code and python code in expressions.

copyright:
  1. 2010 by the Jinja Team.
license:

BSD, see LICENSE for more details.

Classes

Failure Class that raises a TemplateSyntaxError if called.
Lexer Class that implements a lexer for a given environment.
Token Token class.
TokenStream A token stream is an iterable that yields Tokens. The
TokenStreamIterator The iterator for tokenstreams.

Exceptions

TemplateSyntaxError(message, lineno[, name, ...]) Raised to tell the user that there is a problem with the template.

Functions

compile_rules(environment) Compiles all the rules from the environment into a list of rules.
count_newlines(value) Count the number of newline characters in the string.
describe_token(token) Returns a description of the token.
describe_token_expr(expr) Like describe_token but for token expressions.
get_lexer(environment) Return a lexer which is probably cached.
next(iterator[, default]) Return the next item from the iterator.

Defined

  • LRUCache
  • TOKEN_ADD
  • TOKEN_ASSIGN
  • TOKEN_BLOCK_BEGIN
  • TOKEN_BLOCK_END
  • TOKEN_COLON
  • TOKEN_COMMA
  • TOKEN_COMMENT
  • TOKEN_COMMENT_BEGIN
  • TOKEN_COMMENT_END
  • TOKEN_DATA
  • TOKEN_DIV
  • TOKEN_DOT
  • TOKEN_EOF
  • TOKEN_EQ
  • TOKEN_FLOAT
  • TOKEN_FLOORDIV
  • TOKEN_GT
  • TOKEN_GTEQ
  • TOKEN_INITIAL
  • TOKEN_INTEGER
  • TOKEN_LBRACE
  • TOKEN_LBRACKET
  • TOKEN_LINECOMMENT
  • TOKEN_LINECOMMENT_BEGIN
  • TOKEN_LINECOMMENT_END
  • TOKEN_LINESTATEMENT_BEGIN
  • TOKEN_LINESTATEMENT_END
  • TOKEN_LPAREN
  • TOKEN_LT
  • TOKEN_LTEQ
  • TOKEN_MOD
  • TOKEN_MUL
  • TOKEN_NAME
  • TOKEN_NE
  • TOKEN_OPERATOR
  • TOKEN_PIPE
  • TOKEN_POW
  • TOKEN_RAW_BEGIN
  • TOKEN_RAW_END
  • TOKEN_RBRACE
  • TOKEN_RBRACKET
  • TOKEN_RPAREN
  • TOKEN_SEMICOLON
  • TOKEN_STRING
  • TOKEN_SUB
  • TOKEN_TILDE
  • TOKEN_VARIABLE_BEGIN
  • TOKEN_VARIABLE_END
  • TOKEN_WHITESPACE
  • deque
  • float_re
  • ignore_if_empty
  • ignored_tokens
  • integer_re
  • itemgetter
  • k
  • name_re
  • newline_re
  • operator_re
  • operators
  • re
  • reverse_operators
  • string_re
  • v
  • whitespace_re

Table Of Contents

Previous topic

make_attrgetter

Next topic

Failure Class