<% for .... %> <% endfor %> Syntax

55 views
Skip to first unread message

Calvin Young

unread,
Sep 14, 2012, 8:52:16 PM9/14/12
to mako-d...@googlegroups.com
I just stumbled upon this post on Hacker News, in which one user suggests writing a "for" loop using this syntax: <% for r in rows %> ${r.name} <% endfor %>


Seeing has how this post is over 3 years old, is this just the old Mako syntax?  Is there any way to enable it in the latest version of Mako?  I find it much more readable, so it'd be great to be able to use it.

Michael Bayer

unread,
Sep 14, 2012, 9:56:03 PM9/14/12
to mako-d...@googlegroups.com
that syntax is not correct.

the "for" block is via the % for / %endfor pair.

If you want a "for" all on one line, the best you can do is a list/generator comprehension:

${" ".join(r.name for r in rows)}


Reply all
Reply to author
Forward
0 new messages