Skip to content
Myr

parser.py

This file

Path

jinja2/parser.py

783 lines · 30.0 KiB · Python

Last changed by

Added support for optional `scoped` modifier to blocks.Armin Ronacherbefore adoption74a0cd9

History of this file

Take it

The walk stopped after 200 commits: lines older than b217886 point at it.

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 1–7why, one step back
1# -*- coding: utf-8 -*-
2"""3 jinja2.parser4 ~~~~~~~~~~~~~56 Implements the template parser.7

Copyright switch to "The Jinja Team".Armin Ronacherbefore adoption62ccd1b

line 8why, one step back
8 :copyright: (c) 2009 by the Jinja Team.

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 9–11why, one step back
9 :license: BSD, see LICENSE for more details.
10"""11from jinja2 import nodes

simplified from importsArmin Ronacherbefore adoptiona78d276

line 12why, one step back
12from jinja2.exceptions import TemplateSyntaxError, TemplateAssertionError

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 13–15why, one step back
13
1415_statement_keywords = frozenset(['for', 'if', 'block', 'extends', 'print',

switched back to explicit set for assignments. {% foo = 42 %} becomes {% set foo = 42 %} and {% foo.something() }} becomes {{ void(foo.something() }} with this commit.Armin Ronacherbefore adoption0a2ac69

lines 16–17why, one step back
16 'macro', 'include', 'from', 'import',
17 'set'])

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 18–21why, one step back
18_compare_operators = frozenset(['eq', 'ne', 'lt', 'lteq', 'gt', 'gteq'])
192021class Parser(object):

First extension interface documentation and updates in that interfaceArmin Ronacherbefore adoption023b5e9

lines 22–23why, one step back
22 """This is the central parsing class Jinja2 uses. It's passed to
23 extensions and can be used to parse expressions or statements.

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 24–25why, one step back
24 """
25

Added support for `Environment.compile_expression`.Armin Ronacherbefore adoptionba6e25a

lines 26–27why, one step back
26 def __init__(self, environment, source, name=None, filename=None,
27 state=None):

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 28why, one step back
28 self.environment = environment

Added support for `Environment.compile_expression`.Armin Ronacherbefore adoptionba6e25a

line 29why, one step back
29 self.stream = environment._tokenize(source, name, filename, state)

improved exception system. now both name (load name) and filename are passed.Armin Ronacherbefore adoption7f15ef8

line 30why, one step back
30 self.name = name

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 31–33why, one step back
31 self.filename = filename
32 self.closed = False33 self.extensions = {}

First extension interface documentation and updates in that interfaceArmin Ronacherbefore adoption023b5e9

line 34why, one step back
34 for extension in environment.extensions.itervalues():

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 35–36why, one step back
35 for tag in extension.tags:
36 self.extensions[tag] = extension.parse

First extension interface documentation and updates in that interfaceArmin Ronacherbefore adoption023b5e9

line 37why, one step back
37 self._last_identifier = 0

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 38why, one step back
38

improved exception system. now both name (load name) and filename are passed.Armin Ronacherbefore adoption7f15ef8

lines 39–45why, one step back
39 def fail(self, msg, lineno=None, exc=TemplateSyntaxError):
40 """Convenience method that raises `exc` with the message, passed41 line number or last line number as well as the current name and42 filename.43 """44 if lineno is None:45 lineno = self.stream.current.lineno

fixed a bug in error reporting and some small documentation updatesArmin Ronacherbefore adoption61a5a24

line 46why, one step back
46 raise exc(msg, lineno, self.name, self.filename)

improved exception system. now both name (load name) and filename are passed.Armin Ronacherbefore adoption7f15ef8

line 47why, one step back
47

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 48why, one step back
48 def is_tuple_end(self, extra_end_rules=None):

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 49why, one step back
49 """Are we at the end of a tuple?"""

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 50why, one step back
50 if self.stream.current.type in ('variable_end', 'block_end', 'rparen'):

First extension interface documentation and updates in that interfaceArmin Ronacherbefore adoption023b5e9

line 51why, one step back
51 return True

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

lines 52–53why, one step back
52 elif extra_end_rules is not None:
53 return self.stream.current.test_any(extra_end_rules)

First extension interface documentation and updates in that interfaceArmin Ronacherbefore adoption023b5e9

lines 54–62why, one step back
54 return False
5556 def free_identifier(self, lineno=None):57 """Return a new free identifier as :class:`~jinja2.nodes.InternalName`."""58 self._last_identifier += 159 rv = object.__new__(nodes.InternalName)60 nodes.Node.__init__(rv, 'fi%d' % self._last_identifier, lineno=lineno)61 return rv62

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 63–64why, one step back
63 def parse_statement(self):
64 """Parse a single statement."""

switched back to explicit set for assignments. {% foo = 42 %} becomes {% set foo = 42 %} and {% foo.something() }} becomes {{ void(foo.something() }} with this commit.Armin Ronacherbefore adoption0a2ac69

line 65why, one step back
65 token = self.stream.current

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 66why, one step back
66 if token.type != 'name':

improved exception system. now both name (load name) and filename are passed.Armin Ronacherbefore adoption7f15ef8

line 67why, one step back
67 self.fail('tag name expected', token.lineno)

switched back to explicit set for assignments. {% foo = 42 %} becomes {% set foo = 42 %} and {% foo.something() }} becomes {{ void(foo.something() }} with this commit.Armin Ronacherbefore adoption0a2ac69

lines 68–76why, one step back
68 if token.value in _statement_keywords:
69 return getattr(self, 'parse_' + self.stream.current.value)()70 if token.value == 'call':71 return self.parse_call_block()72 if token.value == 'filter':73 return self.parse_filter_block()74 ext = self.extensions.get(token.value)75 if ext is not None:76 return ext(self)

improved exception system. now both name (load name) and filename are passed.Armin Ronacherbefore adoption7f15ef8

line 77why, one step back
77 self.fail('unknown tag %r' % token.value, token.lineno)

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 78–81why, one step back
78
79 def parse_statements(self, end_tokens, drop_needle=False):80 """Parse multiple statements into a list until one of the end tokens81 is reached. This is used to parse the body of statements as it also

First extension interface documentation and updates in that interfaceArmin Ronacherbefore adoption023b5e9

lines 82–87why, one step back
82 parses template data if appropriate. The parser checks first if the
83 current token is a colon and skips it if there is one. Then it checks84 for the block end and parses until if one of the `end_tokens` is85 reached. Per default the active token in the stream at the end of86 the call is the matched end token. If this is not wanted `drop_needle`87 can be set to `True` and the end token is removed.

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 88–89why, one step back
88 """
89 # the first token may be a colon for python compatibility

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 90why, one step back
90 self.stream.skip_if('colon')

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 91–99why, one step back
91
92 # in the future it would be possible to add whole code sections93 # by adding some sort of end of statement token and parsing those here.94 self.stream.expect('block_end')95 result = self.subparse(end_tokens)9697 if drop_needle:98 self.stream.next()99 return result

switched back to explicit set for assignments. {% foo = 42 %} becomes {% set foo = 42 %} and {% foo.something() }} becomes {{ void(foo.something() }} with this commit.Armin Ronacherbefore adoption0a2ac69

lines 100–107why, one step back
100
101 def parse_set(self):102 """Parse an assign statement."""103 lineno = self.stream.next().lineno104 target = self.parse_assign_target()105 self.stream.expect('assign')106 expr = self.parse_tuple()107 return nodes.Assign(target, expr, lineno=lineno)

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 108–111why, one step back
108
109 def parse_for(self):110 """Parse a for loop."""111 lineno = self.stream.expect('name:for').lineno

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 112why, one step back
112 target = self.parse_assign_target(extra_end_rules=('name:in',))

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 113why, one step back
113 self.stream.expect('name:in')

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

lines 114–115why, one step back
114 iter = self.parse_tuple(with_condexpr=False,
115 extra_end_rules=('name:recursive',))

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 116why, one step back
116 test = None

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 117why, one step back
117 if self.stream.skip_if('name:if'):

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 118why, one step back
118 test = self.parse_expression()

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 119why, one step back
119 recursive = self.stream.skip_if('name:recursive')

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 120–124why, one step back
120 body = self.parse_statements(('name:endfor', 'name:else'))
121 if self.stream.next().value == 'endfor':122 else_ = []123 else:124 else_ = self.parse_statements(('name:endfor',), drop_needle=True)

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

lines 125–126why, one step back
125 return nodes.For(target, iter, body, else_, test,
126 recursive, lineno=lineno)

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 127–131why, one step back
127
128 def parse_if(self):129 """Parse an if construct."""130 node = result = nodes.If(lineno=self.stream.expect('name:if').lineno)131 while 1:

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

line 132why, one step back
132 node.test = self.parse_tuple(with_condexpr=False)

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 133–151why, one step back
133 node.body = self.parse_statements(('name:elif', 'name:else',
134 'name:endif'))135 token = self.stream.next()136 if token.test('name:elif'):137 new_node = nodes.If(lineno=self.stream.current.lineno)138 node.else_ = [new_node]139 node = new_node140 continue141 elif token.test('name:else'):142 node.else_ = self.parse_statements(('name:endif',),143 drop_needle=True)144 else:145 node.else_ = []146 break147 return result148149 def parse_block(self):150 node = nodes.Block(lineno=self.stream.next().lineno)151 node.name = self.stream.expect('name').value

Added support for optional `scoped` modifier to blocks.Armin Ronacherbefore adoption74a0cd9

line 152why, one step back
152 node.scoped = self.stream.skip_if('name:scoped')

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 153why, one step back
153 node.body = self.parse_statements(('name:endblock',), drop_needle=True)

all calls are proxied by context.call now so that we can inject environment and context as first arguments. This slows calls down a bit but is a lot more user friendly. Added first draft of FAQArmin Ronacherbefore adoptionfd31049

line 154why, one step back
154 self.stream.skip_if('name:' + node.name)

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 155–173why, one step back
155 return node
156157 def parse_extends(self):158 node = nodes.Extends(lineno=self.stream.next().lineno)159 node.template = self.parse_expression()160 return node161162 def parse_import_context(self, node, default):163 if self.stream.current.test_any('name:with', 'name:without') and \164 self.stream.look().test('name:context'):165 node.with_context = self.stream.next().value == 'with'166 self.stream.skip()167 else:168 node.with_context = default169 return node170171 def parse_include(self):172 node = nodes.Include(lineno=self.stream.next().lineno)173 node.template = self.parse_expression()

Include statements can now be marked with ``ignore missing`` to skipArmin Ronacherbefore adoption37f58ce

lines 174–179why, one step back
174 if self.stream.current.test('name:ignore') and \
175 self.stream.look().test('name:missing'):176 node.ignore_missing = True177 self.stream.skip(2)178 else:179 node.ignore_missing = False

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 180–185why, one step back
180 return self.parse_import_context(node, True)
181182 def parse_import(self):183 node = nodes.Import(lineno=self.stream.next().lineno)184 node.template = self.parse_expression()185 self.stream.expect('name:as')

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

line 186why, one step back
186 node.target = self.parse_assign_target(name_only=True).name

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 187–205why, one step back
187 return self.parse_import_context(node, False)
188189 def parse_from(self):190 node = nodes.FromImport(lineno=self.stream.next().lineno)191 node.template = self.parse_expression()192 self.stream.expect('name:import')193 node.names = []194195 def parse_context():196 if self.stream.current.value in ('with', 'without') and \197 self.stream.look().test('name:context'):198 node.with_context = self.stream.next().value == 'with'199 self.stream.skip()200 return True201 return False202203 while 1:204 if node.names:205 self.stream.expect('comma')

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 206why, one step back
206 if self.stream.current.type == 'name':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 207–208why, one step back
207 if parse_context():
208 break

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

line 209why, one step back
209 target = self.parse_assign_target(name_only=True)

variables starting with one or more underscores are not exportedArmin Ronacherbefore adoption903d168

lines 210–211why, one step back
210 if target.name.startswith('_'):
211 self.fail('names starting with an underline can not '

improved exception system. now both name (load name) and filename are passed.Armin Ronacherbefore adoption7f15ef8

lines 212–213why, one step back
212 'be imported', target.lineno,
213 exc=TemplateAssertionError)

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 214why, one step back
214 if self.stream.skip_if('name:as'):

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

lines 215–216why, one step back
215 alias = self.parse_assign_target(name_only=True)
216 node.names.append((target.name, alias.name))

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 217–218why, one step back
217 else:
218 node.names.append(target.name)

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 219why, one step back
219 if parse_context() or self.stream.current.type != 'comma':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 220–224why, one step back
220 break
221 else:222 break223 if not hasattr(node, 'with_context'):224 node.with_context = False

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 225why, one step back
225 self.stream.skip_if('comma')

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 226–231why, one step back
226 return node
227228 def parse_signature(self, node):229 node.args = args = []230 node.defaults = defaults = []231 self.stream.expect('lparen')

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 232why, one step back
232 while self.stream.current.type != 'rparen':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 233–234why, one step back
233 if args:
234 self.stream.expect('comma')

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

line 235why, one step back
235 arg = self.parse_assign_target(name_only=True)

fixed bug with parameter parsingArmin Ronacherbefore adoptione9411b4

line 236why, one step back
236 arg.set_ctx('param')

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 237why, one step back
237 if self.stream.skip_if('assign'):

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 238–243why, one step back
238 defaults.append(self.parse_expression())
239 args.append(arg)240 self.stream.expect('rparen')241242 def parse_call_block(self):243 node = nodes.CallBlock(lineno=self.stream.next().lineno)

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 244why, one step back
244 if self.stream.current.type == 'lparen':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 245–251why, one step back
245 self.parse_signature(node)
246 else:247 node.args = []248 node.defaults = []249250 node.call = self.parse_expression()251 if not isinstance(node.call, nodes.Call):

improved exception system. now both name (load name) and filename are passed.Armin Ronacherbefore adoption7f15ef8

line 252why, one step back
252 self.fail('expected call', node.lineno)

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 253–264why, one step back
253 node.body = self.parse_statements(('name:endcall',), drop_needle=True)
254 return node255256 def parse_filter_block(self):257 node = nodes.FilterBlock(lineno=self.stream.next().lineno)258 node.filter = self.parse_filter(None, start_inline=True)259 node.body = self.parse_statements(('name:endfilter',),260 drop_needle=True)261 return node262263 def parse_macro(self):264 node = nodes.Macro(lineno=self.stream.next().lineno)

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

line 265why, one step back
265 node.name = self.parse_assign_target(name_only=True).name

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 266–273why, one step back
266 self.parse_signature(node)
267 node.body = self.parse_statements(('name:endmacro',),268 drop_needle=True)269 return node270271 def parse_print(self):272 node = nodes.Output(lineno=self.stream.next().lineno)273 node.nodes = []

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 274why, one step back
274 while self.stream.current.type != 'block_end':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 275–279why, one step back
275 if node.nodes:
276 self.stream.expect('comma')277 node.nodes.append(self.parse_expression())278 return node279

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

lines 280–281why, one step back
280 def parse_assign_target(self, with_tuple=True, name_only=False,
281 extra_end_rules=None):

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

lines 282–285why, one step back
282 """Parse an assignment target. As Jinja2 allows assignments to
283 tuples, this function can parse all allowed assignment targets. Per284 default assignments to tuples are parsed, that can be disable however285 by setting `with_tuple` to `False`. If only assignments to names are

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

lines 286–287why, one step back
286 wanted `name_only` can be set to `True`. The `extra_end_rules`
287 parameter is forwarded to the tuple parsing function.

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

lines 288–293why, one step back
288 """
289 if name_only:290 token = self.stream.expect('name')291 target = nodes.Name(token.value, 'store', lineno=token.lineno)292 else:293 if with_tuple:

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

lines 294–295why, one step back
294 target = self.parse_tuple(simplified=True,
295 extra_end_rules=extra_end_rules)

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

lines 296–299why, one step back
296 else:
297 target = self.parse_primary(with_postfix=False)298 target.set_ctx('store')299 if not target.can_assign():

improved exception system. now both name (load name) and filename are passed.Armin Ronacherbefore adoption7f15ef8

lines 300–301why, one step back
300 self.fail('can\'t assign to %r' % target.__class__.
301 __name__.lower(), target.lineno)

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

lines 302–304why, one step back
302 return target
303304 def parse_expression(self, with_condexpr=True):

First extension interface documentation and updates in that interfaceArmin Ronacherbefore adoption023b5e9

line 305why, one step back
305 """Parse an expression. Per default all expressions are parsed, if

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

line 306why, one step back
306 the optional `with_condexpr` parameter is set to `False` conditional

First extension interface documentation and updates in that interfaceArmin Ronacherbefore adoption023b5e9

lines 307–308why, one step back
307 expressions are not parsed.
308 """

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

lines 309–311why, one step back
309 if with_condexpr:
310 return self.parse_condexpr()311 return self.parse_or()

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 312–315why, one step back
312
313 def parse_condexpr(self):314 lineno = self.stream.current.lineno315 expr1 = self.parse_or()

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 316why, one step back
316 while self.stream.skip_if('name:if'):

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 317why, one step back
317 expr2 = self.parse_or()

Fixed a bug with the loop context of a for loop if the iterator passed has a volatile `__len__` like the listreverseiterator. `else` in inline if-expressions is optional now.Armin Ronacherbefore adoption547d0b6

lines 318–321why, one step back
318 if self.stream.skip_if('name:else'):
319 expr3 = self.parse_condexpr()320 else:321 expr3 = None

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 322–328why, one step back
322 expr1 = nodes.CondExpr(expr2, expr1, expr3, lineno=lineno)
323 lineno = self.stream.current.lineno324 return expr1325326 def parse_or(self):327 lineno = self.stream.current.lineno328 left = self.parse_and()

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 329why, one step back
329 while self.stream.skip_if('name:or'):

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 330–336why, one step back
330 right = self.parse_and()
331 left = nodes.Or(left, right, lineno=lineno)332 lineno = self.stream.current.lineno333 return left334335 def parse_and(self):336 lineno = self.stream.current.lineno

Priority of `not` raised. It's now possible to write `not foo in bar`Armin Ronacherbefore adoptiond89f0f3

line 337why, one step back
337 left = self.parse_not()

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 338why, one step back
338 while self.stream.skip_if('name:and'):

Priority of `not` raised. It's now possible to write `not foo in bar`Armin Ronacherbefore adoptiond89f0f3

line 339why, one step back
339 right = self.parse_not()

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 340–343why, one step back
340 left = nodes.And(left, right, lineno=lineno)
341 lineno = self.stream.current.lineno342 return left343

Priority of `not` raised. It's now possible to write `not foo in bar`Armin Ronacherbefore adoptiond89f0f3

lines 344–349why, one step back
344 def parse_not(self):
345 if self.stream.current.test('name:not'):346 lineno = self.stream.next().lineno347 return nodes.Not(self.parse_not(), lineno=lineno)348 return self.parse_compare()349

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 350–358why, one step back
350 def parse_compare(self):
351 lineno = self.stream.current.lineno352 expr = self.parse_add()353 ops = []354 while 1:355 token_type = self.stream.current.type356 if token_type in _compare_operators:357 self.stream.next()358 ops.append(nodes.Operand(token_type, self.parse_add()))

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 359why, one step back
359 elif self.stream.skip_if('name:in'):

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 360–374why, one step back
360 ops.append(nodes.Operand('in', self.parse_add()))
361 elif self.stream.current.test('name:not') and \362 self.stream.look().test('name:in'):363 self.stream.skip(2)364 ops.append(nodes.Operand('notin', self.parse_add()))365 else:366 break367 lineno = self.stream.current.lineno368 if not ops:369 return expr370 return nodes.Compare(expr, ops, lineno=lineno)371372 def parse_add(self):373 lineno = self.stream.current.lineno374 left = self.parse_sub()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 375why, one step back
375 while self.stream.current.type == 'add':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 376–384why, one step back
376 self.stream.next()
377 right = self.parse_sub()378 left = nodes.Add(left, right, lineno=lineno)379 lineno = self.stream.current.lineno380 return left381382 def parse_sub(self):383 lineno = self.stream.current.lineno384 left = self.parse_concat()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 385why, one step back
385 while self.stream.current.type == 'sub':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 386–394why, one step back
386 self.stream.next()
387 right = self.parse_concat()388 left = nodes.Sub(left, right, lineno=lineno)389 lineno = self.stream.current.lineno390 return left391392 def parse_concat(self):393 lineno = self.stream.current.lineno394 args = [self.parse_mul()]

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 395why, one step back
395 while self.stream.current.type == 'tilde':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 396–404why, one step back
396 self.stream.next()
397 args.append(self.parse_mul())398 if len(args) == 1:399 return args[0]400 return nodes.Concat(args, lineno=lineno)401402 def parse_mul(self):403 lineno = self.stream.current.lineno404 left = self.parse_div()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 405why, one step back
405 while self.stream.current.type == 'mul':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 406–414why, one step back
406 self.stream.next()
407 right = self.parse_div()408 left = nodes.Mul(left, right, lineno=lineno)409 lineno = self.stream.current.lineno410 return left411412 def parse_div(self):413 lineno = self.stream.current.lineno414 left = self.parse_floordiv()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 415why, one step back
415 while self.stream.current.type == 'div':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 416–424why, one step back
416 self.stream.next()
417 right = self.parse_floordiv()418 left = nodes.Div(left, right, lineno=lineno)419 lineno = self.stream.current.lineno420 return left421422 def parse_floordiv(self):423 lineno = self.stream.current.lineno424 left = self.parse_mod()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 425why, one step back
425 while self.stream.current.type == 'floordiv':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 426–434why, one step back
426 self.stream.next()
427 right = self.parse_mod()428 left = nodes.FloorDiv(left, right, lineno=lineno)429 lineno = self.stream.current.lineno430 return left431432 def parse_mod(self):433 lineno = self.stream.current.lineno434 left = self.parse_pow()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 435why, one step back
435 while self.stream.current.type == 'mod':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 436–444why, one step back
436 self.stream.next()
437 right = self.parse_pow()438 left = nodes.Mod(left, right, lineno=lineno)439 lineno = self.stream.current.lineno440 return left441442 def parse_pow(self):443 lineno = self.stream.current.lineno444 left = self.parse_unary()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 445why, one step back
445 while self.stream.current.type == 'pow':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 446–454why, one step back
446 self.stream.next()
447 right = self.parse_unary()448 left = nodes.Pow(left, right, lineno=lineno)449 lineno = self.stream.current.lineno450 return left451452 def parse_unary(self):453 token_type = self.stream.current.type454 lineno = self.stream.current.lineno

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 455why, one step back
455 if token_type == 'sub':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 456–458why, one step back
456 self.stream.next()
457 node = self.parse_unary()458 return nodes.Neg(node, lineno=lineno)

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 459why, one step back
459 if token_type == 'add':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 460–464why, one step back
460 self.stream.next()
461 node = self.parse_unary()462 return nodes.Pos(node, lineno=lineno)463 return self.parse_primary()464

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

line 465why, one step back
465 def parse_primary(self, with_postfix=True):

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 466why, one step back
466 token = self.stream.current

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 467why, one step back
467 if token.type == 'name':

some more documentation updates and minor code cleanups. Additionally True and true in the template are the same now, same for false/False and none/None.Armin Ronacherbefore adoption9bb7e47

lines 468–471why, one step back
468 if token.value in ('true', 'false', 'True', 'False'):
469 node = nodes.Const(token.value in ('true', 'True'),470 lineno=token.lineno)471 elif token.value in ('none', 'None'):

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 472–475why, one step back
472 node = nodes.Const(None, lineno=token.lineno)
473 else:474 node = nodes.Name(token.value, 'load', lineno=token.lineno)475 self.stream.next()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 476why, one step back
476 elif token.type == 'string':

added support for implicit string literal concatenationArmin Ronacherbefore adoption4778bda

lines 477–479why, one step back
477 self.stream.next()
478 buf = [token.value]479 lineno = token.lineno

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 480why, one step back
480 while self.stream.current.type == 'string':

added support for implicit string literal concatenationArmin Ronacherbefore adoption4778bda

lines 481–484why, one step back
481 buf.append(self.stream.current.value)
482 self.stream.next()483 node = nodes.Const(''.join(buf), lineno=lineno)484 elif token.type in ('integer', 'float'):

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 485–486why, one step back
485 self.stream.next()
486 node = nodes.Const(token.value, lineno=token.lineno)

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 487why, one step back
487 elif token.type == 'lparen':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 488–490why, one step back
488 self.stream.next()
489 node = self.parse_tuple()490 self.stream.expect('rparen')

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 491why, one step back
491 elif token.type == 'lbracket':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 492why, one step back
492 node = self.parse_list()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 493why, one step back
493 elif token.type == 'lbrace':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 494–495why, one step back
494 node = self.parse_dict()
495 else:

improved exception system. now both name (load name) and filename are passed.Armin Ronacherbefore adoption7f15ef8

line 496why, one step back
496 self.fail("unexpected token '%s'" % (token,), token.lineno)

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

line 497why, one step back
497 if with_postfix:

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 498–500why, one step back
498 node = self.parse_postfix(node)
499 return node500

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

lines 501–502why, one step back
501 def parse_tuple(self, simplified=False, with_condexpr=True,
502 extra_end_rules=None):

First extension interface documentation and updates in that interfaceArmin Ronacherbefore adoption023b5e9

lines 503–510why, one step back
503 """Works like `parse_expression` but if multiple expressions are
504 delimited by a comma a :class:`~jinja2.nodes.Tuple` node is created.505 This method could also return a regular expression instead of a tuple506 if no commas where found.507508 The default parsing mode is a full tuple. If `simplified` is `True`509 only names and literals are parsed. The `no_condexpr` parameter is510 forwarded to :meth:`parse_expression`.

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

lines 511–515why, one step back
511
512 Because tuples do not require delimiters and may end in a bogus comma513 an extra hint is needed that marks the end of a tuple. For example514 for loops support tuples between `for` and `in`. In that case the515 `extra_end_rules` is set to ``['name:in']``.

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 516–518why, one step back
516 """
517 lineno = self.stream.current.lineno518 if simplified:

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

lines 519–520why, one step back
519 parse = lambda: self.parse_primary(with_postfix=False)
520 elif with_condexpr:

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 521why, one step back
521 parse = self.parse_expression

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

lines 522–523why, one step back
522 else:
523 parse = lambda: self.parse_expression(with_condexpr=False)

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 524–528why, one step back
524 args = []
525 is_tuple = False526 while 1:527 if args:528 self.stream.expect('comma')

added parsing code for "for item in seq recursive" and improved parser interface a bitArmin Ronacherbefore adoptionfdf9530

line 529why, one step back
529 if self.is_tuple_end(extra_end_rules):

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 530–531why, one step back
530 break
531 args.append(parse())

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 532why, one step back
532 if self.stream.current.type == 'comma':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 533–543why, one step back
533 is_tuple = True
534 else:535 break536 lineno = self.stream.current.lineno537 if not is_tuple and args:538 return args[0]539 return nodes.Tuple(args, 'load', lineno=lineno)540541 def parse_list(self):542 token = self.stream.expect('lbracket')543 items = []

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 544why, one step back
544 while self.stream.current.type != 'rbracket':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 545–555why, one step back
545 if items:
546 self.stream.expect('comma')547 if self.stream.current.type == 'rbracket':548 break549 items.append(self.parse_expression())550 self.stream.expect('rbracket')551 return nodes.List(items, lineno=token.lineno)552553 def parse_dict(self):554 token = self.stream.expect('lbrace')555 items = []

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 556why, one step back
556 while self.stream.current.type != 'rbrace':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 557–570why, one step back
557 if items:
558 self.stream.expect('comma')559 if self.stream.current.type == 'rbrace':560 break561 key = self.parse_expression()562 self.stream.expect('colon')563 value = self.parse_expression()564 items.append(nodes.Pair(key, value, lineno=key.lineno))565 self.stream.expect('rbrace')566 return nodes.Dict(items, lineno=token.lineno)567568 def parse_postfix(self, node):569 while 1:570 token_type = self.stream.current.type

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 571why, one step back
571 if token_type == 'dot' or token_type == 'lbracket':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 572why, one step back
572 node = self.parse_subscript(node)

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 573why, one step back
573 elif token_type == 'lparen':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 574why, one step back
574 node = self.parse_call(node)

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 575why, one step back
575 elif token_type == 'pipe':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 576why, one step back
576 node = self.parse_filter(node)

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 577why, one step back
577 elif token_type == 'name' and self.stream.current.value == 'is':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 578–584why, one step back
578 node = self.parse_test(node)
579 else:580 break581 return node582583 def parse_subscript(self, node):584 token = self.stream.next()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 585why, one step back
585 if token.type == 'dot':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 586why, one step back
586 attr_token = self.stream.current

Improved attribute and item lookup by allowing template designers to express the priority. foo.bar checks foo.bar first and then foo['bar'] and the other way round.Armin Ronacherbefore adoption6dc6f29

line 587why, one step back
587 self.stream.next()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 588why, one step back
588 if attr_token.type == 'name':

Improved attribute and item lookup by allowing template designers to express the priority. foo.bar checks foo.bar first and then foo['bar'] and the other way round.Armin Ronacherbefore adoption6dc6f29

lines 589–590why, one step back
589 return nodes.Getattr(node, attr_token.value, 'load',
590 lineno=token.lineno)

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 591why, one step back
591 elif attr_token.type != 'integer':

improved exception system. now both name (load name) and filename are passed.Armin Ronacherbefore adoption7f15ef8

line 592why, one step back
592 self.fail('expected name or number', attr_token.lineno)

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 593why, one step back
593 arg = nodes.Const(attr_token.value, lineno=attr_token.lineno)

Improved attribute and item lookup by allowing template designers to express the priority. foo.bar checks foo.bar first and then foo['bar'] and the other way round.Armin Ronacherbefore adoption6dc6f29

line 594why, one step back
594 return nodes.Getitem(node, arg, 'load', lineno=token.lineno)

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 595why, one step back
595 if token.type == 'lbracket':

Improved attribute and item lookup by allowing template designers to express the priority. foo.bar checks foo.bar first and then foo['bar'] and the other way round.Armin Ronacherbefore adoption6dc6f29

line 596why, one step back
596 priority_on_attribute = False

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 597why, one step back
597 args = []

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 598why, one step back
598 while self.stream.current.type != 'rbracket':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 599–605why, one step back
599 if args:
600 self.stream.expect('comma')601 args.append(self.parse_subscribed())602 self.stream.expect('rbracket')603 if len(args) == 1:604 arg = args[0]605 else:

Fixed a bug in the parser that made ``{{ foo[1, 2] }}`` impossible.Armin Ronacherbefore adoptionee2d3c4

line 606why, one step back
606 arg = nodes.Tuple(args, 'load', lineno=token.lineno)

Improved attribute and item lookup by allowing template designers to express the priority. foo.bar checks foo.bar first and then foo['bar'] and the other way round.Armin Ronacherbefore adoption6dc6f29

lines 607–608why, one step back
607 return nodes.Getitem(node, arg, 'load', lineno=token.lineno)
608 self.fail('expected subscript expression', self.lineno)

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 609–612why, one step back
609
610 def parse_subscribed(self):611 lineno = self.stream.current.lineno612

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 613why, one step back
613 if self.stream.current.type == 'colon':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 614–617why, one step back
614 self.stream.next()
615 args = [None]616 else:617 node = self.parse_expression()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 618why, one step back
618 if self.stream.current.type != 'colon':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 619–622why, one step back
619 return node
620 self.stream.next()621 args = [node]622

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 623why, one step back
623 if self.stream.current.type == 'colon':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 624–629why, one step back
624 args.append(None)
625 elif self.stream.current.type not in ('rbracket', 'comma'):626 args.append(self.parse_expression())627 else:628 args.append(None)629

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 630why, one step back
630 if self.stream.current.type == 'colon':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 631–649why, one step back
631 self.stream.next()
632 if self.stream.current.type not in ('rbracket', 'comma'):633 args.append(self.parse_expression())634 else:635 args.append(None)636 else:637 args.append(None)638639 return nodes.Slice(lineno=lineno, *args)640641 def parse_call(self, node):642 token = self.stream.expect('lparen')643 args = []644 kwargs = []645 dyn_args = dyn_kwargs = None646 require_comma = False647648 def ensure(expr):649 if not expr:

improved exception system. now both name (load name) and filename are passed.Armin Ronacherbefore adoption7f15ef8

lines 650–651why, one step back
650 self.fail('invalid syntax for function call expression',
651 token.lineno)

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 652why, one step back
652

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 653why, one step back
653 while self.stream.current.type != 'rparen':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 654–656why, one step back
654 if require_comma:
655 self.stream.expect('comma')656 # support for trailing comma

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 657why, one step back
657 if self.stream.current.type == 'rparen':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 658why, one step back
658 break

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 659why, one step back
659 if self.stream.current.type == 'mul':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 660–662why, one step back
660 ensure(dyn_args is None and dyn_kwargs is None)
661 self.stream.next()662 dyn_args = self.parse_expression()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 663why, one step back
663 elif self.stream.current.type == 'pow':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 664–668why, one step back
664 ensure(dyn_kwargs is None)
665 self.stream.next()666 dyn_kwargs = self.parse_expression()667 else:668 ensure(dyn_args is None and dyn_kwargs is None)

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

lines 669–670why, one step back
669 if self.stream.current.type == 'name' and \
670 self.stream.look().type == 'assign':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 671–692why, one step back
671 key = self.stream.current.value
672 self.stream.skip(2)673 value = self.parse_expression()674 kwargs.append(nodes.Keyword(key, value,675 lineno=value.lineno))676 else:677 ensure(not kwargs)678 args.append(self.parse_expression())679680 require_comma = True681 self.stream.expect('rparen')682683 if node is None:684 return args, kwargs, dyn_args, dyn_kwargs685 return nodes.Call(node, args, kwargs, dyn_args, dyn_kwargs,686 lineno=token.lineno)687688 def parse_filter(self, node, start_inline=False):689 while self.stream.current.type == 'pipe' or start_inline:690 if not start_inline:691 self.stream.next()692 token = self.stream.expect('name')

added support for dotted names in tests and filtersArmin Ronacherbefore adoptionb9e7875

line 693why, one step back
693 name = token.value

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 694why, one step back
694 while self.stream.current.type == 'dot':

added support for dotted names in tests and filtersArmin Ronacherbefore adoptionb9e7875

lines 695–696why, one step back
695 self.stream.next()
696 name += '.' + self.stream.expect('name').value

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 697why, one step back
697 if self.stream.current.type == 'lparen':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 698–702why, one step back
698 args, kwargs, dyn_args, dyn_kwargs = self.parse_call(None)
699 else:700 args = []701 kwargs = []702 dyn_args = dyn_kwargs = None

added support for dotted names in tests and filtersArmin Ronacherbefore adoptionb9e7875

line 703why, one step back
703 node = nodes.Filter(node, name, args, kwargs, dyn_args,

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 704–715why, one step back
704 dyn_kwargs, lineno=token.lineno)
705 start_inline = False706 return node707708 def parse_test(self, node):709 token = self.stream.next()710 if self.stream.current.test('name:not'):711 self.stream.next()712 negated = True713 else:714 negated = False715 name = self.stream.expect('name').value

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 716why, one step back
716 while self.stream.current.type == 'dot':

added support for dotted names in tests and filtersArmin Ronacherbefore adoptionb9e7875

lines 717–718why, one step back
717 self.stream.next()
718 name += '.' + self.stream.expect('name').value

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 719–720why, one step back
719 dyn_args = dyn_kwargs = None
720 kwargs = []

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 721why, one step back
721 if self.stream.current.type == 'lparen':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 722–724why, one step back
722 args, kwargs, dyn_args, dyn_kwargs = self.parse_call(None)
723 elif self.stream.current.type in ('name', 'string', 'integer',724 'float', 'lparen', 'lbracket',

Fixed a broken unittest and fixed a bug that required multiple tests to be put into parentheses for chaning.Armin Ronacherbefore adoptione3290ea

lines 725–729why, one step back
725 'lbrace') and not \
726 self.stream.current.test_any('name:else', 'name:or',727 'name:and'):728 if self.stream.current.test('name:is'):729 self.fail('You cannot chain multiple tests with is')

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 730–751why, one step back
730 args = [self.parse_expression()]
731 else:732 args = []733 node = nodes.Test(node, name, args, kwargs, dyn_args,734 dyn_kwargs, lineno=token.lineno)735 if negated:736 node = nodes.Not(node, lineno=token.lineno)737 return node738739 def subparse(self, end_tokens=None):740 body = []741 data_buffer = []742 add_data = data_buffer.append743744 def flush_data():745 if data_buffer:746 lineno = data_buffer[0].lineno747 body.append(nodes.Output(data_buffer[:], lineno=lineno))748 del data_buffer[:]749750 while self.stream:751 token = self.stream.current

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 752why, one step back
752 if token.type == 'data':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 753why, one step back
753 if token.value:

even more tests, fixed severe bug with autoescaping.Armin Ronacherbefore adoption5411ce7

lines 754–755why, one step back
754 add_data(nodes.TemplateData(token.value,
755 lineno=token.lineno))

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 756why, one step back
756 self.stream.next()

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 757why, one step back
757 elif token.type == 'variable_begin':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 758why, one step back
758 self.stream.next()

added a function to parse assign targes and documented it for the extension interfaceArmin Ronacherbefore adoption09c002e

line 759why, one step back
759 add_data(self.parse_tuple(with_condexpr=True))

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

line 760why, one step back
760 self.stream.expect('variable_end')

This commit makes the parser and lexer use regular string comparison to support jythonAli Afsharbefore adoption272ca2a

line 761why, one step back
761 elif token.type == 'block_begin':

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 762–766why, one step back
762 flush_data()
763 self.stream.next()764 if end_tokens is not None and \765 self.stream.current.test_any(*end_tokens):766 return body

First extension interface documentation and updates in that interfaceArmin Ronacherbefore adoption023b5e9

lines 767–771why, one step back
767 rv = self.parse_statement()
768 if isinstance(rv, list):769 body.extend(rv)770 else:771 body.append(rv)

added author information and fixed small off-by-one bugArmin Ronacherbefore adoptionb217886

lines 772–783why, one step back
772 self.stream.expect('block_end')
773 else:774 raise AssertionError('internal parsing error')775776 flush_data()777 return body778779 def parse(self):780 """Parse the whole template into a `Template` node."""781 result = nodes.Template(self.subparse(), lineno=1)782 result.set_environment(self.environment)783 return result