Groups
Sign in
Groups
Mako Templates for Python
Conversations
About
Send feedback
Help
Empty lines in generated files
152 views
Skip to first unread message
Paul Baumer
unread,
Nov 23, 2017, 9:41:50 AM
11/23/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Mako Templates for Python
Hello,
I have a simple template which looks like:
% if context.bookId:
bookid: ${content.bookId}
% endif
the generated file includes 3 lines instead of (expected) 1. Hence it looks like
<empty line>
bookid: 33
<empty line>
How can I get rid of the empty lines?
Thanks,
Paul
Mike Bayer
unread,
Nov 24, 2017, 5:25:38 PM
11/24/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mako-d...@googlegroups.com
you can put a backslash at the end of a line to suppress trailing whitespace:
http://docs.makotemplates.org/en/latest/syntax.html#newline-filters
t = Template(r"""
<foo>\
% if True:
hi there\
% endif
</foo>
""")
print t.render()
> --
> You received this message because you are subscribed to the Google Groups
> "Mako Templates for Python" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
mako-discuss...@googlegroups.com
.
> To post to this group, send email to
mako-d...@googlegroups.com
.
> Visit this group at
https://groups.google.com/group/mako-discuss
.
> For more options, visit
https://groups.google.com/d/optout
.
Reply all
Reply to author
Forward
0 new messages