/django-route-loader

Webpack loader plugin for Django routes

Primary LanguageJavaScript

django-route-loader

Webpack loader plugin to hook into Django named routes.

Usage

Install the plugin, no Webpack configuration is necessary.

npm install --save django-route-loader

Define the Django route.

from django.conf.urls import include, url

urlpatterns = [
    url(r'^user/(?P<user_id>\d+)/$', user.views.user_prifile, name='user_profile'),
]

Require the route through the plugin.

var userProfileRoute = require('djang-route!?user_profile');

assert.equal(userProfileRoute({user_id: 1337}), 'user/1337/');