Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Native, Pythonic Templatetags for Django
branch: master

Merge pull request #13 from Shanto/master

Django 1.5: Remove deprecated django.utils.hashcompat references
latest commit d40b976ee1
Justin Quick authored
Failed to load latest commit information.
docs setuptools/distribute to the rescue, v0.5.3
example_project fixes to testing and moving example app test to the app itself, versi…
native_tags Update hash.py
.gitignore Version bumped at docs and function name fixed at docstring
LICENSE.txt
MANIFEST.in setuptools/distribute to the rescue, v0.5.3
Makefile
README.rst setuptools/distribute to the rescue, v0.5.3
setup.py setuptools/distribute to the rescue, v0.5.3

README.rst

Native Tags Documentation

Authors: Justin Quick <justquick@gmail.com>
Version: 0.5
pip install django-native-tags==0.5.3

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
  • Error tolerant by letting you specify a fallback return value

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 `Sphinx doc`_

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

justquick [@] the gmails .com
Something went wrong with that request. Please try again.