That's also already done, check
https://github.com/django-extensions/django-extensions/blob/master/django_extensions/management/commands/show_urls.py,
it can be easily converted to JSON (I have a branch that does it, but
it's not up-to-date).

I also have the urls module in JavaScript already, but as part of a
larger library (https://github.com/mlouro/olivejs/blob/master/olive/
urls/urls.js), both have been used in projects.

An example:

/* below is the output from "manage.py show_urls" in JSON format */
olive.urls.load({
    'dashboard': '/dashboard/',
    'time_edit': '/projects/<project_id>/time/save/<time_id>/',
    'task_edit': '/projects/<project_id>/task/save/<task_id>/'
});

olive.urls.get('task_edit', {
        'project_id': 2,
        'task_id': 1
    })



On Mar 24, 3:31 pm, Matt Robenolt <youdontevenk...@gmail.com> wrote:
> I think the biggest problem with translating the reverse() lookup is the
> lack of kwargs and named capture groups in Javascript regex. So a pattern
> such as: /page/(?P<page_id>\d+)/ would not translate whatsoever. Then on the
> Javascript side, we wouldn't be able to use:  reverse('goto_page', [],
> {page_id: 5});  It would have nowhere to map up the page_id variable to. We
> could probably get away with some sort of pseudo regex rules in Javascript.

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

Reply via email to