Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/callowayproject/django-urltags
A Django application that provides URL modification tags
https://github.com/callowayproject/django-urltags
Last synced: 3 months ago
JSON representation
A Django application that provides URL modification tags
- Host: GitHub
- URL: https://github.com/callowayproject/django-urltags
- Owner: callowayproject
- License: apache-2.0
- Created: 2012-09-24T11:47:32.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-09-05T10:57:30.000Z (about 10 years ago)
- Last Synced: 2024-07-31T13:42:45.450Z (3 months ago)
- Language: JavaScript
- Size: 426 KB
- Stars: 4
- Watchers: 7
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - django-urltags - A Django application that provides URL modification tags (JavaScript)
README
==============
Django URLtags
==============Django URLtags is a collection of template tags and filters for manipulating URLs or adding some convenience methods for common practices.
add_qs_param
============**Usage:** ``{% add_qs_param url varname value %}``
This tag intelligently adds or replaces the query string parameter ``varname`` and assigns it ``value``.
``url``, ``varname``, and ``value`` can be static values or variables
Examples
--------**Adding a single query string parameter**
.. code-block:: django
{% add_qs_param http://example.com/ q 1 %}
generates::
http://example.com/?q=1
**Adding a query string parameter to a URL with a query string.**
.. code-block:: django
{% add_qs_param http://example.com/?sort=asc q 1 %}
generates::
http://example.com/?sort=asc&q=1
**Adding a query string parameter to a URL that already has that parameter.**
.. code-block:: django
{% add_qs_param http://example.com/?q=5 q 1 %}
generates::
http://example.com/?q=1
**Adding a query string parameter to a URL that has a page fragment.**
.. code-block:: django
{% add_qs_param http://example.com/#gohere q 1 %}
generates::
http://example.com/?q=1#gohere
add_fragment
============**Usage:** ``{{ url|add_fragment:variable }}`` or ``{{ url|add_fragment:"fragment" }}``
This tag intelligently adds or replaces the URL fragment. You can pass a variable as the parameter to ``add_fragment`` or a static value. You must quote static values.
Example
-------.. code-block:: django
{{ url|add_fragment:"gohere" }}
generates::
http://example.com/#gohere
absurl
======Just like Django's `url tag`_ but adds the domain of the current site.
.. _url tag: https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#url
link
====**Usage:** ``{{ object|link }}``
Outputs the object in a anchor tag which is the equivalent of ``{{ object }}``