Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unnecessary writer statements with \ #155

sqlalchemy-bot opened this issue Nov 12, 2010 · 2 comments

unnecessary writer statements with \ #155

sqlalchemy-bot opened this issue Nov 12, 2010 · 2 comments
bug Something isn't working lexer low priority


Copy link

Migrated issue, originally created by Michael Bayer (@zzzeek)

the use of the end-of-line continuation
(backslash) syntax
can result in the generated python module for a template to contain unnecessary
calls to write empty strings.

import mako.template
print mako.template.Template("<% pass %>\\\nFoo").code

       # SOURCE LINE 1

       # SOURCE LINE 2

I believe these calls __M_writer(u'') are unnecessary. I have a few
templates that
use a lot of line continuations and so I see a lot of these in the
generated code.

A really simple change in mako/ appears to optimize these calls away
(patch is against the 0.3.6 candidate, tag Mako-c8598ab628a0da0d55857196627753dad9849a39):

--- mako/	2010-11-09 19:44:52.000000000 -0500
+++ mako/	2010-11-12 12:17:43.348306483 -0500
@@ -331,7 +331,8 @@

        if match:
            text =
-            self.append_node(parsetree.Text, text)
+            if text:
+                self.append_node(parsetree.Text, text)
            return True
            return False
Copy link

Michael Bayer (@zzzeek) wrote:


Copy link

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added bug Something isn't working low priority lexer labels Nov 26, 2018
@sqlalchemy-bot sqlalchemy-bot added this to the 0.3.6 milestone Nov 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
bug Something isn't working lexer low priority
None yet

No branches or pull requests

1 participant