I'm putting together a quick routine to assemble a horizontal menu bar
in my layout.html file (does one already exist? I only saw the one
called MENU() to create vertical menus). I thought it would be a
simple map-reduce operation, but I'm getting a strange result. Here is
the code in my view file:

{{=response.write(' | '.join(map(lambda m:'<a href="%s">%s</a>'%
(m[2],m[0]),response.menu_user)),False)}}{{pass}}


which produces this (from View Source):
<a href="/user/login">Login</a> | <a href="/user/register">Register
for a new account</a>None

I can't figure out why the "None" is being added at the end. Looking
at the examples on this page, I see a different approach using a for:
loop, so I tried that and sure enough, the results do not have a
"None" hanging on to the end.
code:
{{for m in response.menu_user:}}<a href="{{=m[2]}}">{{=m[0]}}</a> |
{{pass}}

resulting html:
<a href="/user/login">Login</a> | <a href="/user/register">Register
for a new account</a> |

can anyone shed some light on this behavior? I'm stumped. And I'm not
sure how to trace the code execution through the generation of the
view code, either...
btw, I'm running 1.65.0

thanks!
Dan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to