Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 63 lines (46 sloc) 1.961 kB
0fff5b2 @ojii fixed critical bug in parser
authored
1 ==================
2 django-classy-tags
3 ==================
4
5 Please refer to the documentation in the docs/ directory for help. For a HTML
ad51c74 @ojii fixed docs link in README
authored
6 rendered version of it please see `here <http://django-classy-tags.rtfd.org>`_.
0fff5b2 @ojii fixed critical bug in parser
authored
7
dddcd4b @ojii more exclusions in build matrix
authored
8 .. image:: https://travis-ci.org/ojii/django-classy-tags.svg?branch=master
9 :target: https://travis-ci.org/ojii/django-classy-tags
10
0fff5b2 @ojii fixed critical bug in parser
authored
11 ******************
12 About this project
13 ******************
14
15 The goal of this project is to create a new way of writing Django template tags
16 which is fully compatible with the current Django templating infrastructure.
17 This new way should be easy, clean and require as little boilerplate code as
18 possible while still staying as powerful as possible.
19
c1b2af0 @ojii minor readme update
authored
20 Features
21 --------
22
23 * Class based template tags.
24 * Template tag argument parser.
25 * Declarative way to define arguments.
26 * Supports (theoretically infinite) parse-until blocks.
27 * Extensible!
28
29
0fff5b2 @ojii fixed critical bug in parser
authored
30 *****************
31 For the impatient
32 *****************
33
34 This is how a tag looks like using django-classy-tags::
35
ff9a760 @ojii fixed code example
authored
36 from classytags.core import Options
37 from classytags.helpers import AsTag
0fff5b2 @ojii fixed critical bug in parser
authored
38 from classytags.arguments import Argument
39 from django import template
40
41 register = template.Library()
42
f77259d @ojii some docs fixes
authored
43 class Hello(AsTag):
0fff5b2 @ojii fixed critical bug in parser
authored
44 options = Options(
45 Argument('name', required=False, default='world'),
46 'as',
502b0f6 @ojii Fixed old API usage in README.rst as reported by issue 3
authored
47 Argument('varname', required=False, resolve=False)
0fff5b2 @ojii fixed critical bug in parser
authored
48 )
49
f77259d @ojii some docs fixes
authored
50 def get_value(self, context, name):
51 return 'hello %s' % name
52
0fff5b2 @ojii fixed critical bug in parser
authored
53 register.tag(Hello)
54
55 That's your standard *hello world* example. Which can be used like this:
56
57 * ``{% hello %}``: Outputs ``hello world``
58 * ``{% hello "classytags" %}``: Outputs ``hello classytags``
59 * ``{% hello as myvar %}``: Outputs nothing but stores ``hello world`` into the
60 template variable ``myvar``.
61 * ``{% hello "my friend" as othervar %}``: Outputs nothing but stores
ad51c74 @ojii fixed docs link in README
authored
62 ``hello my friend`` into the template variable ``othervar``.
Something went wrong with that request. Please try again.