Skip to main content

Native, Pythonic Templatetags for Django

Project description

Authors:

Justin Quick <justquick@gmail.com>

Version:
0.4

Django Native Tags is a way of making the creation of template tags stupidly simple. Tags are “native” because there is a much closer relationship between the tag in the template and a Python function behind the scenes. The app abstracts the work needed to parse out the templatetag syntax into a useable form for a Python function. For example:

Define an arbitrary function in your templatetags:

def add(x, y):
   return x + y
add.function = True

Use the function in your template:

{% add 1000 100 as num %}
{{ num|intcomma }}

Which outputs:

1,100

Other features of Native Tags:

  • Keyword argument parsing

  • Quoted strings parsed correctly

  • Add templatetags to Django’s builtins (no {% load %} required)

  • Auto resolve of template variables

  • Universal and per-tag caching

  • Straightforward template tag unittesting

The real power of the module comes in the contrib add ons which has tons of tags for various uses including comparisons, regex operations, math operations, and much more. By default it is a functional replacement to James Bennett’s django-template-utils right out of the box

For full documentation, checkout the fancy Sphinx doc

Email me with any questions/concerns/issues/hate mail:

justquick [@] the gmails .com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-native-tags-0.4.tar.gz (20.7 kB view details)

Uploaded Source

File details

Details for the file django-native-tags-0.4.tar.gz.

File metadata

File hashes

Hashes for django-native-tags-0.4.tar.gz
Algorithm Hash digest
SHA256 bd5df81bd2b7fd2bddbdbfbeb0cb424d08b04196d2376fcfbb15a9cbf6bfb9fb
MD5 f4c486cd6b51723fd7cae712cbf76178
BLAKE2b-256 d858edac895737f22438ae82a6f943f592b4c77727fca61b9744132e12228404

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page