Please refer to the documentation in the docs/ directory for more information or visit our
online documentation.
Example
This is how a tag looks like using django-classy-tags:
from classytags.core import Options
from classytags.helpers import AsTag
from classytags.arguments import Argument
from django import template
register = template.Library()
class Hello(AsTag):
options = Options(
Argument('name', required=False, default='world'),
'as',
Argument('varname', required=False, resolve=False)
)
def get_value(self, context, name):
return 'hello %s' % name
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.
Running Tests
You can run tests by executing:
virtualenv env
source env/bin/activate
pip install -r tests/requirements.txt
python setup.py test