django-classy-tags 0.5.1

Class based template tags for Django

Please refer to the documentation in the docs/ directory for help. For a HTML rendered version of it please see here.

About this project

The goal of this project is to create a new way of writing Django template tags which is fully compatible with the current Django templating infrastructure. This new way should be easy, clean and require as little boilerplate code as possible while still staying as powerful as possible.

Features

  • Class based template tags.
  • Template tag argument parser.
  • Declarative way to define arguments.
  • Supports (theoretically infinite) parse-until blocks.
  • Extensible!

For the impatient

This is how a tag looks like using django-classy-tags:

from classytags.core import Tag, Options
from classytags.arguments import Argument
from django import template

register = template.Library()

class Hello(Tag):
    options = Options(
        Argument('name', required=False, default='world'),
        'as',
        Argument('varname', required=False, resolve=False)
    )

    def render_tag(self, context, name, varname):
        output = 'hello %s' % name
        if varname:
            context[varname] = output
            return ''
        return output

register.tag(Hello)

That's your standard hello world example. Which can be used like this:

  • {% hello %}: Outputs hello world
  • {% hello "classytags" %}: Outputs hello classytags
  • {% hello as myvar %}: Outputs nothing but stores hello world into the template variable myvar.
  • {% hello "my friend" as othervar %}: Outputs nothing but stores hello my friend into the template variable othervar.

Author

Jonas Obrist

Pip

django-classy-tags==0.5.1

Classifiers

  • Topic :: Utilities
  • Topic :: Text Processing :: Markup :: HTML
  • Topic :: Software Development :: Libraries :: Python Modules
  • Topic :: Internet :: WWW/HTTP :: Dynamic Content
  • Programming Language :: Python :: 3.3
  • Programming Language :: Python :: 3.2
  • Programming Language :: Python :: 2.7
  • Programming Language :: Python :: 2.6
  • Programming Language :: Python :: 2.5
  • Operating System :: OS Independent
  • Natural Language :: English
  • License :: OSI Approved :: BSD License
  • Intended Audience :: Developers
  • Framework :: Django
  • Development Status :: 5 - Production/Stable
File Type Python Version Uploaded On Downloads
django-classy-tags-0.5.1.tar.gz Source April 7, 2014 145,977
Version Release Date
0.5.1 April 7, 2014
0.5 Feb. 28, 2014
0.4 Jan. 18, 2013
0.3.5 Feb. 28, 2014
0.3.4.1 Aug. 11, 2011
0.3.4 Aug. 11, 2011
0.3.3.1 April 10, 2011
0.3.3 March 3, 2011
0.3.2 March 2, 2011
0.3.1 March 2, 2011
0.3.0 Dec. 16, 2010
0.2.2 Sept. 12, 2010
0.2.1 Sept. 11, 2010
0.2.0 Sept. 11, 2010
0.1.3 Aug. 24, 2010
0.1.2 Aug. 23, 2010
0.1.1 Aug. 11, 2010
0.1.0 Aug. 10, 2010
Date Package Version Action
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.5.1 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.3.4.1 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.1.2 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.1.1 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.1.0 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.2.0 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.2.1 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.2.2 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.3.2 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.3.5 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.3.4 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.4 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.5 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.3.1 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.3.0 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.3.3 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.3.3.1 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags 0.1.3 Release Created
Nov. 4, 2014, 12:59 p.m. django-classy-tags Package Created