Parse an assignment target. As Jinja2 allows assignments to tuples, this function can parse all allowed assignment targets. Per default assignments to tuples are parsed, that can be disable however by setting `with_tuple` to `False`. If only assignments to names are
(self, with_tuple=True, name_only=False,
extra_end_rules=None)
| 354 | return node |
| 355 | |
| 356 | def parse_assign_target(self, with_tuple=True, name_only=False, |
| 357 | extra_end_rules=None): |
| 358 | """Parse an assignment target. As Jinja2 allows assignments to |
| 359 | tuples, this function can parse all allowed assignment targets. Per |
| 360 | default assignments to tuples are parsed, that can be disable however |
| 361 | by setting `with_tuple` to `False`. If only assignments to names are |
| 362 | wanted `name_only` can be set to `True`. The `extra_end_rules` |
| 363 | parameter is forwarded to the tuple parsing function. |
| 364 | """ |
| 365 | if name_only: |
| 366 | token = self.stream.expect('name') |
| 367 | target = nodes.Name(token.value, 'store', lineno=token.lineno) |
| 368 | else: |
| 369 | if with_tuple: |
| 370 | target = self.parse_tuple(simplified=True, |
| 371 | extra_end_rules=extra_end_rules) |
| 372 | else: |
| 373 | target = self.parse_primary() |
| 374 | target.set_ctx('store') |
| 375 | if not target.can_assign(): |
| 376 | self.fail('can\'t assign to %r' % target.__class__. |
| 377 | __name__.lower(), target.lineno) |
| 378 | return target |
| 379 | |
| 380 | def parse_expression(self, with_condexpr=True): |
| 381 | """Parse an expression. Per default all expressions are parsed, if |
no test coverage detected