django-classy-tagsClass based template tags for Django | |
Download |
django-classy-tags Ranking & Summary
Advertisement
- License:
- BSD License
- Publisher Name:
- Jonas Obrist
- Publisher web site:
- http://github.com/ojii/
django-classy-tags Tags
django-classy-tags Description
Class based template tags for Django django-classy-tags's goal 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.For the impatientThis is how a tag looks like using django-classy-tags:from classytags.core import Tag, Optionsfrom classytags.arguments import Argumentfrom django import templateregister = template.Library()class Hello(Tag): options = Options( Argument('name', required=False, default='world'), 'as', Argument('varname', required=False, no_resolve=True) ) def render_tag(self, context, name, varname): output = 'hello %s' % name if varname: context = output return '' return outputregister.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.
django-classy-tags Related Software