Alan, that is a beautiful recursive function.
On Friday, May 31, 2013 10:32:52 AM UTC-7, Alan Etkin wrote:
>
>
> Now I would like to turn this into a nested html-list? How would I
>> accomplish this task in web2py? (possibly by using html-helpers).
>>
>
> # You can put something like the following in the controller or the model
>
> def ulmaker(val):
> ul = UL()
> for k, v in val.iteritems():
> if isinstance(v, dict):
> ul.append(LI(ulmaker(v)))
> else:
> ul.append(LI(v))
> return ul
>
> # And then you can use the function like this:
>
> def action():
> files = {...}
> return dict(filelist=ulmaker(files))
>
> BTW: the admin app also does show an html file tree. Check the app code if
> you need a better example.
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.