{ "info": { "author": "Morgan Aubert", "author_email": "me@morganaubert.name", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "django-js-routes\n################\n\n**Django-js-routes** is a Django application allowing to expose and perform reverse lookups of\nDjango named URL patterns on the client side.\n\n.. contents:: Table of Contents\n :local:\n\nMain requirements\n=================\n\nPython 3.4+, Django 2.0+.\n\nInstallation\n============\n\nTo install Django-js-routes, please use the pip_ command as follows:\n\n.. code-block:: shell\n\n $ pip install --pre django-js-routes\n\nOnce the package is installed, you'll have to add the application to ``INSTALLED_APPS`` in your\nproject's settings module:\n\n.. code-block:: python\n\n INSTALLED_APPS = (\n # all other apps...\n 'js_routes',\n )\n\nYou can then define which URL patterns or URL namespaces you want to expose to the client side by\nsetting the ``JS_ROUTES_INCLUSION_LIST`` setting. This setting allows to define which URLs should be\nserialized and made available to the client side through the generated and / or exported Javascript\nhelper. This list should contain only URL pattern names or namespaces. Here is an example:\n\n.. code-block:: python\n\n JS_ROUTES_INCLUSION_LIST = [\n 'home',\n 'catalog:product_list',\n 'catalog:product_detail',\n ]\n\nNote that if a namespace is included in this list, all the underlying URLs will be made available to\nthe client side through the generated Javascript helper. Django-js-routes is safe by design in the\nsense that *only* the URLs that you configure in this inclusion list will be publicly exposed on the\nclient side.\n\nOnce the list of URLs to expose is configured, you can add the ``{% js_routes %}`` tag to your base\ntemplate in order to ensure that the Javascript helper is available to you when you need it:\n\n.. code-block:: html\n\n {% load js_routes_tags %}\n \n \n \n \n \n {% js_routes %}\n \n \n\nUsage\n=====\n\nThe URL patterns you configured through the ``JS_ROUTES_INCLUSION_LIST`` setting can then be\nreversed using the generated ``window.reverseUrl`` function, which can be used pretty much the\n\"same\" way you'd use `reverse `_ on\nthe Django side:\n\n.. code-block:: javascript\n\n window.reverseUrl('home');\n window.reverseUrl('catalog:product_list');\n window.reverseUrl('catalog:product_detail', productId);\n window.reverseUrl('catalog:product_detail', { pk: productId });\n\nSettings\n========\n\nJS_ROUTES_INCLUSION_LIST\n------------------------\n\nDefault: ``[]``\n\nThe ``JS_ROUTES_INCLUSION_LIST`` setting allows to define the URL patterns and URL namespaces that\nshould be exposed to the client side through the generated Javascript helper.\n\nAdvanced features\n=================\n\nInserting only the serialized URLs in Django templates\n------------------------------------------------------\n\nBy default, the ``{% js_routes %}`` template tag only allows to trigger the generation of the\nserialized URLs (which are stored in a Javascript object on the ``window`` object) and to include a\nJavascript URL resolver function in your HTML using the Django's\n`static `_ template tag.\nActually, a standard use of the ``{% js_routes %}`` statement is equivalent to:\n\n.. code-block:: html\n\n {% js_routes routes_only=True %}\n \n\nThe ``routes_only`` option allows to only include the serialized URLs in the output of\n``{% js_routes %}``. It gives you the ability to include the Javascript URL resolver that comes with\nDjango-js-routes using another ``static`` statement. This also allows you to cache the output of the\n``{% js_routes routes_only=True %}`` statement if you want (so that serialized URLs are not\ngenerated for every request).\n\nDumping the Javascript routes resolver\n--------------------------------------\n\nAs explained earlier, the ``{% js_routes %}`` template tag triggers the generation of the serialized\nURLs and includes a client-side URL resolver in the final HTML. One downside of this behaviour is\nthat the serialized URLs need to be generated every time your HTML template is rendered.\n\nInstead it is possible to just dump the whole list of serialized URLs AND the URL resolver function\ninto a single Javascript module file. This can be achieved using the ``dump_routes_resolver``\ncommand, which can be used as follows:\n\n.. code-block:: shell\n\n $ python manage.py dump_routes_resolver --format=default --output=my_exported_resolver.js\n\nThe ``--output`` option allows to specify to which file the serialized routes and resolver function\nshould be saved while the ``--format`` option allows to specify the Javascript format to use.\n\n``--format`` accepts the following values:\n\n* ``default`` includes the routes as an object that is associated to the ``window`` object while the\n URL resolver is available through the ``window.reverseUrl`` function (this corresponds to the\n behaviour provided by a standard use of the ``{% js_routes %}`` template tag)\n* ``es6`` allows to save the routes and the URL resolver as an ES6 module where the ``reverseUrl``\n function is the default export\n\nLicense\n=======\n\nMIT. See ``LICENSE`` for more details.\n\n.. _pip: https://github.com/pypa/pip\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ellmetha/django-js-routes", "keywords": "django urls reverse routes resolution frontend js javascript export", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-js-routes", "package_url": "https://pypi.org/project/django-js-routes/", "platform": "", "project_url": "https://pypi.org/project/django-js-routes/", "project_urls": { "Homepage": "https://github.com/ellmetha/django-js-routes" }, "release_url": "https://pypi.org/project/django-js-routes/0.1.0.dev0/", "requires_dist": null, "requires_python": "", "summary": "Expose and perform reverse lookups of Django URLs in the frontend world.", "version": "0.1.0.dev0" }, "last_serial": 5728644, "releases": { "0.1.0.dev0": [ { "comment_text": "", "digests": { "md5": "3365a969e68aff4c80ac8d3a80b72162", "sha256": "ff797caecf701f9772457da2b38add1955f0b3339f5431a3d63cf295b1d4c73f" }, "downloads": -1, "filename": "django_js_routes-0.1.0.dev0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3365a969e68aff4c80ac8d3a80b72162", "packagetype": "bdist_wheel", "python_version": "3.7", "requires_python": null, "size": 17020, "upload_time": "2019-08-26T02:38:22", "url": "https://files.pythonhosted.org/packages/e5/1a/f644a4a3234d6f2f9a43add120cd58daa6d98d9579a69cf879921731654a/django_js_routes-0.1.0.dev0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7087682b8acde3384d89034a0b8a60be", "sha256": "7b0568b20d5e3d148987b5d2e726799b934edf4506c1d82208e599332205833b" }, "downloads": -1, "filename": "django-js-routes-0.1.0.dev0.tar.gz", "has_sig": false, "md5_digest": "7087682b8acde3384d89034a0b8a60be", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8740, "upload_time": "2019-08-26T02:38:20", "url": "https://files.pythonhosted.org/packages/e3/76/390aecbf4ad116f549b8443a18ababc61f8a98a80af4db6ef8c1634fe2e1/django-js-routes-0.1.0.dev0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3365a969e68aff4c80ac8d3a80b72162", "sha256": "ff797caecf701f9772457da2b38add1955f0b3339f5431a3d63cf295b1d4c73f" }, "downloads": -1, "filename": "django_js_routes-0.1.0.dev0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3365a969e68aff4c80ac8d3a80b72162", "packagetype": "bdist_wheel", "python_version": "3.7", "requires_python": null, "size": 17020, "upload_time": "2019-08-26T02:38:22", "url": "https://files.pythonhosted.org/packages/e5/1a/f644a4a3234d6f2f9a43add120cd58daa6d98d9579a69cf879921731654a/django_js_routes-0.1.0.dev0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7087682b8acde3384d89034a0b8a60be", "sha256": "7b0568b20d5e3d148987b5d2e726799b934edf4506c1d82208e599332205833b" }, "downloads": -1, "filename": "django-js-routes-0.1.0.dev0.tar.gz", "has_sig": false, "md5_digest": "7087682b8acde3384d89034a0b8a60be", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8740, "upload_time": "2019-08-26T02:38:20", "url": "https://files.pythonhosted.org/packages/e3/76/390aecbf4ad116f549b8443a18ababc61f8a98a80af4db6ef8c1634fe2e1/django-js-routes-0.1.0.dev0.tar.gz" } ] }