Control statements don't follow line-wrapping rules

Issue #195 new
created an issue

% for item in [ 'some', 'long', 'list', 'of', 'items', ]: ${item} % endfor


CompileException: Fragment 'for item in [' is not a partial control statement in file...

Adding backslashes to the end of every line works, but normal Python wrapping ought to apply here.

Comments (1)

  1. Michael Bayer repo owner

    Note that Mako's syntax for "%" is that the control line ending is denoted as a newline. This ticket is a feature request to make control lines behave more similarly to pure python.

    This request is extremely difficult to implement, and I have no plans to do this myself. I will of course accept patches, but the issue is pretty much a much more difficult version of #20 (since a colon can appear not just in a string literal but also a dictionary literal), which you'll note was open for five years until someone came along to resolve it finally.

    We use the actual Python parser to parse Python, giving it a fragment of code that we've identified using known boundaries. In the case of %, the end of the line is the boundary. Making a ':' the boundary means that like #20 we need to use intelligent heuristics across all characters up to the ':' to ensure we aren't mis-interpreting a ':' inside of a string or dictionary literal.

  2. Log in to comment