Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A template tag constructor library for Django.
Python
branch: master

This branch is 146 commits ahead of rob-b:master

Failed to load latest commit information.
docs Add an as_default meta option to AsTag and bump to version 2.4
ttag Add an as_default meta option to AsTag and bump to version 2.4
.gitignore Added docs to gitignore file.
AUTHORS Added missing AUTHORS file.
CHANGELOG Add an as_default meta option to AsTag and bump to version 2.4
LICENSE Fix all imports and add a license.
MANIFEST.in Exclude docs/_build from source distribution
README.rst Tab to space.
runtests.py Stop expecting ttag test templates to live in the ttag.tests.setup mo…
setup.py 1.0 release
tagcon.LICENSE
tox.ini Added tox configuration and test runner.

README.rst

django-ttag

TTag is a template tag constructor library for Django created for the purpose of making writing template tags easier.

The tag syntax is modelled on Django's friendly syntaxes for models and forms. Here is a full example tag:

class Welcome(ttag.Tag)
    user = ttag.Arg()
    fallback = ttag.Arg(named=True, default='Hi!')

    def output(self, data)
        name = data['user'].get_full_name()
        if name:
            return 'Hi, %s!' % name
        return data['fallback']

This would produce a tag named welcome which can be used like this:

{% welcome current_user fallback "Hello, anonymous." %}

More comprehensive usage and reference documentation can be found in the docs directory, or at http://packages.python.org/django-ttag/.

Something went wrong with that request. Please try again.